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

相关推荐
用户47949283569155 小时前
React 终于出手了:彻底终结 useEffect 的"闭包陷阱"
前端·javascript·react.js
哈__6 小时前
React Native 鸿蒙跨平台开发:PixelRatio 实现鸿蒙端图片的高清显示
javascript·react native·react.js
wszy18096 小时前
外部链接跳转:从 App 打开浏览器的正确姿势
java·javascript·react native·react.js·harmonyos
wordbaby6 小时前
TanStack Router 实战:如何构建经典的“左侧菜单 + 右侧内容”后台布局
前端·react.js
爱吃奶酪的松鼠丶7 小时前
React长列表,性能优化。关于循环遍历的时候,key是用对象数据中的ID还是用索引
javascript·react.js·性能优化
wayne21410 小时前
Zustand 入门:React Native 状态管理的正确用法
react native
Mintopia10 小时前
意图OS是未来软件形态,它到底解决了什么问题?
人工智能·react native·前端工程化
Mintopia10 小时前
🤖 AI 决策 + 意图OS:未来软件形态的灵魂共舞
前端·人工智能·react native
哈__11 小时前
从入门小白到精通,玩转 React Native 鸿蒙跨平台开发:TouchableOpacity 触摸反馈组件
react native·react.js·harmonyos
古茗前端团队12 小时前
视频播放弱网提示实现
react.js