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

相关推荐
走到天涯海角2 小时前
react里面的长列表渲染优化
前端·react.js·前端框架
一叶难遮天10 小时前
开启RN之旅——常用API
react native·rn api·移动端跨平台开发
晴天1611 小时前
React 版本迭代解析:从15到19 核心差异-Day40
前端·react.js·前端框架
欢迎来到祖安!12 小时前
企业微信 iPad 协议私有化方案:毫秒级事件推送与高并发承载实践
ios·企业微信·ipad
倾颜13 小时前
AI Chat 长会话性能实践:消息虚拟化、动态高度与流式滚动设计
前端·react.js·node.js
天道kabuto14 小时前
前端每日知识点:React Fiber 与 AI 流式长文本渲染:从调度原理到工程落地
react.js
光影少年1 天前
react navite跨端项目的痛点、踩过哪些坑、怎么解决
前端·react native·react.js
一叶难遮天1 天前
开启RN之旅——系统组件
react native·移动端开发·移动端跨平台
杉氧2 天前
打破边界(二):在 React Native 中嵌入原生 UI 组件 (Native UI Components)
android·前端·react native