【问题标题】:React Native landscape mode for only one pageReact Native 横向模式仅适用于一页
【发布时间】:2021-12-10 10:03:52
【问题描述】:

是否可以在本机反应中让应用程序以纵向模式运行但一页以横向模式运行?我知道在 xcode 中你必须在开始时选择纵向或横向,所以我有点困惑如何使应用程序中的所有页面都成为纵向,除了一个。

【问题讨论】:

标签: react-native


【解决方案1】:

有一个非常好的包:react-native-orientation

唯一的缺点是您需要在应用程序的每个场景中指定方向:

Orientation.lockToPortrait();

Orientation.lockToLandscape();

【讨论】:

  • 我也一直在使用它,但在 RN0.44 中无法再使用它:'(
  • 在 react navigation v6 中你可以这样做:
【解决方案2】:

在反应导航 v6 中你可以这样做:

  <AppStack.Screen
    name="VehiclesDetailsAuction"
    component={VehiclesDetailsAuction}
    options={{ orientation: 'portrait' }}
  />
  <AppStack.Screen
    name="VehicleImageView"
    component={VehicleImageView}
    options={{ orientation: 'all' }}
  />

【讨论】:

    【解决方案3】:

    希望这个回答对你有帮助

    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"
    

    【讨论】:

    • IOS呢?
    • Xcode 有一个选项 general->deployemnt info-> 设备方向设备方向复选框,您可以根据需要选择土地空间左土地空间右
    【解决方案4】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-08
    • 2022-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    • 2016-09-05
    相关资源
    最近更新 更多