我有一个带有选项卡栏的应用程序,每个选项卡上都有导航控制器.当用户摇动设备时,导航控制器中将显示一个UIImageView
作为子视图.但UIImageView
必须包含一个特殊的图像,这取决于设备的当前方向.
如果我只写
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
//Code
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight||interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
//Code
}
}
如果用户在摇晃前旋转设备,视图就会变得疯狂.
Is there a method to get iPhones current orientation?