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中Redux基础和路由介绍
javascript·react.js·ecmascript
伟笑3 小时前
React 的常用钩子函数在Vue中是如何设计体现出来的。
前端·react.js
FogLetter4 小时前
React组件开发进阶:本地存储与自定义Hooks的艺术
前端·javascript·react.js
AliciaIr7 小时前
深入React事件机制:解密“合成事件”与“事件委托”的底层奥秘
javascript·react.js
心.c8 小时前
后台管理系统-权限管理
javascript·react.js·github
杨进军9 小时前
实现 React 函数组件渲染
前端·react.js·前端框架
归于尽9 小时前
被 50px 到 200px 的闪烁整破防了?useLayoutEffect 和 useEffect 的区别原来在这
前端·react.js
杨进军9 小时前
实现 React Fragment 节点渲染
前端·react.js·前端框架
杨进军9 小时前
实现 React 类组件渲染
前端·react.js·前端框架
FogLetter9 小时前
React组件开发之Todos基础:从零打造一个优雅的待办事项应用
前端·javascript·react.js