ios - 无法在 iPad iO 上锁定屏幕方向

标签 ios react-native ipad expo screen-orientation

注意我知道已经有很多关于此的帖子。但所有的都有些过时,没有一个能解决问题,因此我发布了一个新的。

问题

无法锁定 ipad 的特定屏幕方向。

"expo": "~44.0.0",
"expo-screen-orientation": "^4.1.2",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
(Ands loads of others that arent relevent)

信息

尝试将屏幕方向锁定为横向。 这里有一个问题:在移动设备上它应该是纵向的,但在平板电脑上应该是横向的。移动设备工作正常(两个方向),但在平板电脑上 - 似乎无法正常工作。

是的,我确实将 "requireFullScreen": true 添加到 app.json。并且 app.json 不包含 orientation 属性(也尝试过)。

小花絮 - 尝试在 app.json 上将 orientation 设置为横向,在 iPhone 上没问题,但在 iPad 上 - 什么也没做。我仍然可以很好地旋转屏幕。

代码

在最顶层的应用程序 (app.js) 中,我创建了一个简单的方法(在 function App() 中):

  const foo = async () => {
    await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE_LEFT);
  };

我称之为:foo();

然后返回(不相关)。请注意,应用会像这样返回 export default registerRootComponent(App);

如果使用 iPhone - 它工作正常。但是使用 iPad - 我可以旋转屏幕(也就是未锁定)。

尝试了很多不同的 iPad(模拟器),但似乎都不起作用。

如前所述 - 有很多报告,但似乎没有一个是最新的或有效的。

最佳答案

来自世博docs :

Apple added support for split view mode to iPads in iOS 9. This changed how the screen orientation is handled by the system. To put the matter shortly, for the iOS, your iPad is always in the landscape mode unless you open two applications side by side. In order to be able to lock screen orientation using this module you will need to disable support for this feature. For more information about the split view mode, check out the official Apple documentation.

当然这基本上什么也没告诉我们。

关于ios - 无法在 iPad iO 上锁定屏幕方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71164395/

相关文章:

iOS : NSInputStream/NSOutputStream - CFNetwork SSLHandshake failed (-9806)

node.js - 为什么客户端的 socket.disconnect() 不会在服务器上触发断开连接事件?

ipad - 如何阻止我的自定义键盘从 'floating' 或在 iPad 上脱离

ios - CocoaPods 未正确安装

ios - 在 SQLite 中保存 UIBezierPath

javascript - 我如何制作一个计时器?

iphone - 展开和折叠 UITableview

jquery - 有没有办法在 safari(网络浏览器)上隐藏 iPad 键盘

iphone - 如何多次购买耗材?

ios - 带有 ios native 部分的 Realm 和 React Native