仅对一页反应原生景观模式

Ada*_*atz 9 react-native

是否有可能在本机反应中使应用程序以纵向模式运行但是在横向模式下运行一个页面?我知道在xcode中你必须在开头选择肖像或风景,所以我对如何制作应用程序肖像中的所有页面有点困惑,除了一个.

Ajm*_*san 15

在 React Navigation v6 中你可以这样做:

  <AppStack.Screen
    name="VehiclesDetailsAuction"
    component={VehiclesDetailsAuction}
    options={{ orientation: 'portrait' }}
  />
  <AppStack.Screen
    name="VehicleImageView"
    component={VehicleImageView}
    options={{ orientation: 'all' }}
  />
Run Code Online (Sandbox Code Playgroud)


G. *_*ide 8

有一个非常完善的包:反应本地方向

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

Orientation.lockToPortrait();

要么

Orientation.lockToLandscape();

  • 我也一直在使用它,但不能让它在 RN0.44 中工作了:'( (3认同)
  • 在React导航v6中,你可以这样做: &lt;AppStack.Screen name="VehiclesDetailsAuction" component={VehiclesDetailsAuction} options={{orientation: 'portrait' }} /&gt; &lt;AppStack.Screen name="VehicleImageView" component={VehicleImageView}选项={{ 方向: '全部' }} /&gt; (2认同)