Iphone iOS-UIViewcontroller是否检测旋转?
我正在使用Iphone iOS-UIViewcontroller是否检测旋转?,iphone,objective-c,ios,uiviewcontroller,orientation,Iphone,Objective C,Ios,Uiviewcontroller,Orientation,我正在使用willRotateToInterfaceOrientation检测旋转并根据方向移动项目 问题是当页面第一次加载时,这个方法没有被调用,所以它没有尝试将对象移动到正确的位置 解决方案是什么?您需要根据方向设置界面 if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) { // do something } else if ([UIDevice currentDevice].orie
willRotateToInterfaceOrientation
检测旋转并根据方向移动项目
问题是当页面第一次加载时,这个方法没有被调用,所以它没有尝试将对象移动到正确的位置
解决方案是什么?您需要根据方向设置界面
if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) {
// do something
} else if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) {
// do something else
}
然后重复,对于所有不同的设备方向,我从我的
ui应用程序中手动检测到ui接口定向
,并且我在视图上手动调用willanimaterotationInterfaceoOrientation
,是否尝试将其限制在某个方向?例如,让它以横向模式启动。实际上,UIInterfaceOrientation是处理方向的正确方法