gpt4 book ai didi

iphone - iPad 平放在表面时的启动方向

转载 作者:技术小花猫 更新时间:2023-10-29 10:41:42 25 4
gpt4 key购买 nike

我有以下代码:

 -(void)viewWillAppear:(BOOL)animated {

UIDeviceOrientation orientation = [[UIDevice currentDevice] UIInterface];

if(orientation==UIDeviceOrientationLandscapeLeft || orientation==UIDeviceOrientationLandscapeRight) {
NSLog(@"Device Landscape");
} else {
NSLog(@"Device Portrait");
}

}

这非常适合模拟器和设备,但前提是 iPad 不平放在表面上,例如,如果我将 iPad 放在我的 table 上并加载 View ,它会显示它的肖像,所以我无法检测到 View 出现时的方向。

关于调用 viewWillAppear 时检测界面方向的最佳方法有什么想法吗?

谢谢

最佳答案

您应该使用 [self interfaceOrientation] 而不是设备方向。

关于iphone - iPad 平放在表面时的启动方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3901337/

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