我有一个 UIWebView
,我想根据它是纵向还是横向加载不同的 URL。我如何确定我当前在 viewWillAppear
中的方向?
最佳答案
使用 UIApplication 的 statusBarOrientation
属性(property)。如果您使用设备方向,如果它是 UIDeviceOrientationFaceUp
,您可能会遇到问题。或 UIDeviceOrientationFaceDown
.
示例
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsLandscape(orientation))
{
// Do something when in landscape
}
else
{
// Do something when in portrait
}
关于iOS:如何确定 viewWillAppear 中的当前方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7957599/