React Native将 ipad 端软件设置为横屏显示后关闭 Modal 弹窗报错

问题:

将 ipad 端软件设置为横屏显示后,关闭 Modal 弹窗报错。

Modal was presented with 0x2 orientations mask but the application only supports 0x18.Add more interface orientations to your app's Info.plist to fix this.NOTE: This will crash in non-dev mode.

解决:

supportedOrientations={['portrait', 'landscape']}

typescript 复制代码
<Modal supportedOrientations={['portrait', 'landscape']} />

supportedOrientations

用于指定在设备切换横竖屏方向时,modal 会在哪些屏幕朝向下跟随旋转。在 iOS上,除了本属性外,还会受到应用的 Info.plist 文件中UISupportedInterfaceOrientations的限制。如果还设置了presentationStyle属性为pageSheet或formSheet,则在 iOS 上本属性将被忽略。

参考:
https://github.com/facebook/react-native/issues/13951
https://reactnative.cn/docs/modal#supportedorientations

相关推荐
hhhjhl20 小时前
React Native 三方库「react-native-sha256」的鸿蒙化适配指南
react native·华为·harmonyos
2601_9499706921 小时前
React Native 三方库「react-native-version-check」的鸿蒙化适配指南
react native·华为·harmonyos
hhhjhl21 小时前
React Native 三方库「react-native-proximity」的鸿蒙化适配指南
react native·华为·harmonyos
2601_9499706921 小时前
React Native 三方库「react-native-media-notification」的鸿蒙化适配指南
react native·华为·harmonyos
liuchangng21 小时前
React 19 + Vite 6 实战:从教材 PDF 到 866 词间隔重复单词 App
前端·react.js·pdf·vite·开源项目
GitCode官方1 天前
从大语言模型到具身智能:百度百舸 LoongForge 入驻 AtomGit
人工智能·react native·百度·harmonyos·atomgit
鸿蒙开发1 天前
Three.js 首帧卡顿排查:compileAsync 之后,为什么还会停一下?
react.js·three.js
小李科技2 天前
【性能优化】事件委托:目标定位与 React/Vue 实战
前端·vue.js·react.js·面试·性能优化·前端框架
csj502 天前
前端基础之《React(16)—Modal组件封装》
前端·react.js
ZoeLandia4 天前
React11:数据请求与 TanStack Query
前端·react.js·typescript·react