如何检查iPhone现在的位置(横向或纵向)? [英] How to check in which position (landscape or portrait) is the iPhone now?
本文介绍了如何检查iPhone现在的位置(横向或纵向)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带标签栏的应用程序,每个标签中都有导航控制器。当用户摇动设备时, UIImageView
在导航控制器中显示为子视图。但 UIImageView
必须包含特殊图像,具体取决于设备的当前方向。
I have an app with a tab bar, and nav controllers in each tab. When user shakes the device, a UIImageView
appears as a child view in the nav controller. But the UIImageView
must contain a special image, depending on the device's current orientation.
如果我只写
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
//Code
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight||interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
//Code
}
}
视图如果用户在摇晃之前旋转设备,则会发疯
The view just goes crazy if user rotated the device before shaking.
有没有办法让iPhone进行当前定位?
推荐答案
使用 [[UIDevice currentDevice] orientation]
方法,如指定这里。
这篇关于如何检查iPhone现在的位置(横向或纵向)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文