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

相关推荐
DoraBigHead31 分钟前
React 架构重生记:从递归地狱到时间切片
前端·javascript·react.js
Joyee6913 小时前
RN 的初版架构——UI 布局与绘制
前端·react native
Joyee6914 小时前
RN 的初版架构——通信机制
前端·react native
Jerry_Rod5 小时前
react+umijs 项目快速学习
前端·react.js
AliPaPa5 小时前
你可能忽略了useSyncExternalStore + useOptimistic + useTransition
前端·react.js
GISer_Jing8 小时前
AI/CICD/Next/React Native&Taro内容
人工智能·react native·taro
小仙女喂得猪9 小时前
2025 Android原生开发者角度的Flutter 笔记整理(对比ReactNative)
android·flutter·react native
Takklin10 小时前
Vue 与 React 应用初始化机制对比 - 前端框架思考笔记
前端·react.js
Sherry00711 小时前
【译】React 新手踩坑指南:9 个让你秃头的常见错误 🚨
javascript·react.js·前端框架
今天头发还在吗1 天前
【React】TimePicker进阶:解决开始时间可大于结束时间的业务场景与禁止自动排版
javascript·react.js·ant design