gpt4 book ai didi

ios - iPhone 5 屏幕在横向比例时系统说它不是横向

转载 作者:行者123 更新时间:2023-11-28 08:51:38 25 4
gpt4 key购买 nike

我有一个应用程序,当它从横向更改为纵向或反之时,需要更改它的尺寸。我已经注册了这样的通知:

NSNotificationCenter.defaultCenter().addObserver(self, selector: "rotated", name: UIDeviceOrientationDidChangeNotification, object: nil);

我收到了通知,但有一种情况它失败了。当我拿起手机,将其切换为横屏模式,然后将其平放在 table 上而不倾斜时,我收到一条通知,提示它已不再是横屏模式,但我得到的尺寸仍然是旧尺寸。这就是我检查的方式:

let isLandscape = UIDeviceOrientationIsLandscape(currentDevice.orientation);

这是一个日志:

从纵向开始:

Landscape: false
Bounds (0.0, 0.0, 320.0, 568.0)

将手机侧放:

Landscape: true
Bounds (0.0, 0.0, 568.0, 320.0)

平躺在 table 上:

Landscape: false
Bounds (0.0, 0.0, 568.0, 320.0)

我对此很陌生,所以我可能使用了错误的 API。

最佳答案

这是一个愚蠢的错误。我假设只有两个方向,但我查看了 UIDeviceOrientation 枚举,发现有几个:

case Portrait // Device oriented vertically, home button on the bottom
case PortraitUpsideDown // Device oriented vertically, home button on the top
case LandscapeLeft // Device oriented horizontally, home button on the right
case LandscapeRight // Device oriented horizontally, home button on the left
case FaceUp // Device oriented flat, face up
case FaceDown // Device oriented flat, face down

所以我的“不是风景就是肖像”的假设是不正确的。

关于ios - iPhone 5 屏幕在横向比例时系统说它不是横向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34049821/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com