在iOS 6中手动更改方向
问题描述:
我在iOS 5中手动更改方向,一切正常。但在iOS 6中,键盘未改变方向.UIApplication statusBarOrientation不起作用。相反在iOS 6中手动更改方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
这个:
答
试试这个
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
UPDATE:
在iOS系统7 SDK &的Xcode 5:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
答
方法statusBarOrientation
仅在supportedInterfaceOrientations
回调返回0时有效。要使您的上一个代码正常工作,可以在调用statusBarOrientation
方法之前将标志设置为true。一旦调用statusBarOrientation
,该标志就可以重置。
当您发现此标志为true时,您可以从supportedInterfaceOrientations
返回0。