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

相关推荐
Peter 谭4 小时前
React Hooks 实现原理深度解析:从基础到源码级理解
前端·javascript·react.js·前端框架·ecmascript
LuckyLay5 小时前
React百日学习计划——Deepseek版
前端·学习·react.js
程序猿阿伟7 小时前
《React Native与Flutter:社交应用中用户行为分析与埋点统计的深度剖析》
flutter·react native·react.js
学渣y9 小时前
React状态管理-对state进行保留和重置
javascript·react.js·ecmascript
进取星辰10 小时前
25、Tailwind:魔法速记术——React 19 样式新思路
前端·react.js·前端框架
Bl_a_ck12 小时前
【React】Craco 简介
开发语言·前端·react.js·typescript·前端框架
寧笙(Lycode)14 小时前
React系列——HOC高阶组件的封装与使用
前端·react.js·前端框架
赵大仁16 小时前
React vs Vue:点击外部事件处理的对比与实现
javascript·vue.js·react.js
Zero10171317 小时前
【React的useMemo钩子详解】
前端·react.js·前端框架
郝开1 天前
扩展:React 项目执行 yarn eject 后的 scripts 目录结构详解
react.js·前端框架·react