【发布时间】:2021-12-10 10:03:52
【问题描述】:
是否可以在本机反应中让应用程序以纵向模式运行但一页以横向模式运行?我知道在 xcode 中你必须在开始时选择纵向或横向,所以我有点困惑如何使应用程序中的所有页面都成为纵向,除了一个。
【问题讨论】:
标签: react-native
是否可以在本机反应中让应用程序以纵向模式运行但一页以横向模式运行?我知道在 xcode 中你必须在开始时选择纵向或横向,所以我有点困惑如何使应用程序中的所有页面都成为纵向,除了一个。
【问题讨论】:
标签: react-native
有一个非常好的包:react-native-orientation
唯一的缺点是您需要在应用程序的每个场景中指定方向:
Orientation.lockToPortrait();
或
Orientation.lockToLandscape();
【讨论】:
在反应导航 v6 中你可以这样做:
<AppStack.Screen
name="VehiclesDetailsAuction"
component={VehiclesDetailsAuction}
options={{ orientation: 'portrait' }}
/>
<AppStack.Screen
name="VehicleImageView"
component={VehicleImageView}
options={{ orientation: 'all' }}
/>
【讨论】:
希望这个回答对你有帮助
Project->_text->android->app->src->main->AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reactnativeweb">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
在你的
中只添加这一行android:screenOrientation="landscape"
【讨论】:
【讨论】: