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

相关推荐
鹤鸣的日常4 小时前
前端运行时动态环境变量方案
前端·react.js·docker·前端框架·vue·gitlab
vim怎么退出12 小时前
Dive into React——事件系统
前端·react.js·源码阅读
打小就很皮...15 小时前
基于 Python + LangChain + React 实现智能发票识别与验真系统实战
前端·react.js·langchain·ocr·发票识别
圣殿骑士-Khtangc1 天前
单智能体落地实战:从 ReAct 到 Production-Ready AI Agent 全链路解析
人工智能·react.js
Patrick_Wilson1 天前
router.replace 之后紧跟 reload,页面为什么无限刷新?
javascript·react.js·浏览器
xiaofeichaichai1 天前
React Hooks
前端·javascript·react.js
wordbaby1 天前
rn-cross-calendar:一个兼容 React 18/19、RN/RNOH 的跨平台日历组件
前端·react native·harmonyos
markfeng81 天前
Redux 与 React-Redux 深度解析:从原理到最佳实践
react.js
微扬嘴角1 天前
react篇4--setState、LazyLoad和Hooks
前端·javascript·react.js
光影少年1 天前
React 项目常见优化方案
前端·react.js·前端框架