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

相关推荐
符方昊17 小时前
React 19 对比 React 16 新特性解析
前端·react.js
不会敲代码117 小时前
前端组件化样式隔离实战:React CSS Modules、styled-components 与 Vue scoped 对比
css·vue.js·react.js
阿虎儿19 小时前
React Hook 入门指南
前端·react.js
阿虎儿20 小时前
React Context 详解:从入门到性能优化
前端·vue.js·react.js
青青家的小灰灰1 天前
React 反模式(Anti-Patterns)排查手册:从性能杀手到逻辑陷阱
前端·javascript·react.js
青青家的小灰灰1 天前
告别 Prop Drilling:Context API 的陷阱、Reducer 模式与原子化状态库原理
前端·javascript·react.js
ssshooter2 天前
看完就懂 useSyncExternalStore
前端·javascript·react.js
Live000002 天前
在鸿蒙中使用 Repeat 渲染嵌套列表,修改内层列表的一个元素,页面不会更新
前端·javascript·react native
青青家的小灰灰2 天前
迈向全栈新时代:SSR/SSG 原理、Next.js 架构与 React Server Components (RSC) 实战
前端·javascript·react.js
青青家的小灰灰2 天前
透视 React 内核:Diff 算法、合成事件与并发特性的深度解析
前端·javascript·react.js