【问题标题】:React Native, expo-screen-orientationReact Native,展览屏幕方向
【发布时间】:2021-12-22 08:12:22
【问题描述】:

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

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',
  },
});


横向模式,带切屏

【问题讨论】:

    标签: ios react-native expo screen-orientation


    【解决方案1】:

    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

    【讨论】:

    • 我将 expo-updates 更新为 0.10.15,现在问题消失了。感谢您的快速回复
    猜你喜欢
    • 2021-09-21
    • 2018-03-19
    • 1970-01-01
    • 1970-01-01
    • 2022-07-26
    • 2021-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多