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

相关推荐
hxmmm1 小时前
react性能优化两大策略bailout和eagerState
react.js
冴羽1 小时前
能让 GitHub 删除泄露的苹果源码还有 8000 多个相关仓库的 DMCA 是什么?
前端·javascript·react.js
ERIC_s5 小时前
记一次 Next.js + K8s + CDN 缓存导致 RSC 泄漏的排查与修复
前端·react.js·程序员
浪遏6 小时前
好久不见 ,甚是想念 | vibe coding 一个react native 全栈项目| 小账兜
react native·全栈·vibecoding
FogLetter9 小时前
手写useInterval:告别闭包陷阱,玩转React定时器!
前端·react.js
用户479492835691520 小时前
React DevTools 组件名乱码?揭秘从开发到生产的代码变形记
前端·react.js
开发者小天1 天前
React中使用useParams
前端·javascript·react.js
GISer_Jing1 天前
跨端框架对决:React Native vs Flutter深度对比
flutter·react native·react.js
WYiQIU1 天前
大厂前端岗重复率极高的场景面试原题解析
前端·javascript·vue.js·react.js·面试·状态模式
lichenyang4531 天前
从零到一:编写一个简单的 Umi 插件并发布到 npm
前端·react.js·前端框架