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

相关推荐
白兰地空瓶6 小时前
🚀你以为你在写 React?其实你在“搭一套前端操作系统”
前端·react.js
专注前端30年14 小时前
在日常开发项目中Vue与React应该如何选择?
前端·vue.js·react.js
风无雨15 小时前
在 React 中实现数学公式显示:使用 KaTeX 和 react-katex
前端·react.js·前端框架
前端无涯17 小时前
react组件(2)---State 与生命周期
前端·react.js
前端无涯17 小时前
react组件(3)---组件间的通信
前端·react.js
前端无涯17 小时前
react组件(1)---从入门到上手
react.js·前端框架
风止何安啊19 小时前
一场组件的进化脱口秀——React从 “类” 到 “hooks” 的 “改头换面”
前端·react.js·面试
前端无涯19 小时前
react---JSX完全指南:从基础语法到进阶实战
react.js·前端框架
Alair‎20 小时前
202React-Query:useMutation
react.js
是杉杉吖~21 小时前
《5 分钟上手 React Flex 容器:从 0 搭建响应式卡片列表》
前端·react.js·前端框架