[英]How to lock device orientation for React Native
Hi I want to know how to lock device orientation for React Native for both android and iOS.嗨,我想知道如何为 android 和 iOS 的 React Native 锁定设备方向。 I need to lock the orientation once user rotate the device and application will lock with portrait or lanscape
一旦用户旋转设备,我需要锁定方向,应用程序将锁定纵向或横向
For Android安卓版
For Android platform all we need to do is navigate to AndroidManifest.xml file that lies inside android/app/src/main
path and add the property android:screenOrientation
with a value or portrait or landscape respectively.对于 Android 平台,我们需要做的就是导航到位于
android/app/src/main
路径内的AndroidManifest.xml文件,并分别添加属性android:screenOrientation
与值或纵向或横向。 The property has to be added in xml element activity which is a child of application element.该属性必须添加到 xml 元素活动中,该活动是应用程序元素的子元素。
Simply add it as shown below:只需添加它,如下所示:
For iOS对于 iOS
For iOS platform we need to open Xcode, and select the desired orientation modes from the Device Orientation section.对于 iOS 平台,我们需要打开 Xcode,然后从 Device Orientation 部分选择所需的方向模式。 As shown below:
如下所示:
And you are set!你已经准备好了! Rebuild your project to verify that the changes are configured.
重建您的项目以验证更改是否已配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.