gpt4 book ai didi

iphone - UIViewController 的 UIInterfaceOrientation

转载 作者:行者123 更新时间:2023-11-29 11:11:32 26 4
gpt4 key购买 nike

我尝试检查当前呈现的 View Controller 的 UIInterfaceOrientation,但出于某种原因,它总是返回横向。

 UIInterfaceOrientation currentOrientation = (UIInterfaceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
if (currentOrientation == UIInterfaceOrientationPortrait){
self.scrollView_.colMargin = 50;
} else {
self.scrollView_.colMargin = 130;
}

知道为什么吗?

最佳答案

您可以按如下方式检查方向:

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
if( orientation == UIDeviceOrientationPortrait ) ...

关于iphone - UIViewController 的 UIInterfaceOrientation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11349557/

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