ios - React Native,面向展览屏幕

标签 ios react-native expo screen-orientation

我正在开发 IOS React Native 项目(使用带有裸工作流程的 expo)。 默认情况下,我的应用程序使用纵向模式,但有时我需要将屏幕方向更改为横向模式。我使用 expo-screen-orientation 库来更改屏幕方向。当应用程序更改屏幕方向时,我在发布的应用程序中遇到问题,尽管在 Debug模式下它工作得很好(IOS模拟器/IOS设备)。在 Release模式下,我遇到了切屏问题。请检查附件中的照片

import { StatusBar } from 'expo-status-bar';
import {StyleSheet, Text, View, Button} from 'react-native';
import * as ScreenOrientation from 'expo-screen-orientation';

export default function App() {

  const foo = async()=>{
    await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE_LEFT);
  }

  return (
    <View style={styles.container}>
      <Text style={{paddingTop:50}}>Open up App.js to start working on your app!</Text>
      <Button title="Rotate" onPress={foo}/>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#cccccc',
    alignItems: 'center',
    justifyContent: 'flex-start',
  },
});

Portrait mode


横向模式,带切屏

Landscape mode with cut screen

最佳答案

expo SDK 43 的 expo-updates 存在错误,您需要将 package.json 中的 expo-updates 更新到 v0.10.15,然后 npm install 并运行 pod install。这为我解决了这个问题。其他人指出,将 expo 降级到 SDK 42 也解决了问题。

更多信息请点击这里: https://github.com/expo/expo/issues/14967#issuecomment-966811190

关于ios - React Native,面向展览屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69901242/

相关文章:

ios - 如何在WKWebView中重写urlRequest

ios - 如何使用 UITapGestureRecognizer 调用 didSelectRowAtIndexPath 方法?

ios - 访问 Cocoapods resource_bundles

ios - 如何用XCode的Interface Builder设计一个超长的Scrollview

css - React Native 上的文本缩进

android - 如何使用 react-native-svg 库加载本地 svg 文件

react-native - 使用react-native-dialog,如何获取Dialog.Input内容?

javascript - 无法在 react 导航中将 Prop 从 Stacknavigator 传递到 DrawerNavigator

javascript - 世博会:生成的 APK 不会安装在 Android 版本 < 8

xcode - Expo 未加载 (React-Native) -- 空 Expo SDK 版本