因为ios sdk更新后接口变化的问题,ios6前后的版本需要实现不同的旋转控制方法,如果兼容ios6前后的版本,则两种方法都需要实现。
ios6之前实现如下方法
// Override to allow orientations other than the default portrait orientation.
// This method is deprecated on ios6- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsPortrait( interfaceOrientation );
}
ios6及以后实现如下方法
// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead- (NSUInteger) supportedInterfaceOrientations{
#ifdef __IPHONE_6_0
return UIInterfaceOrientationMaskAllButUpsideDown;
#endif
}
- (BOOL) shouldAutorotate {
return YES;
}
本文介绍如何在iOS应用中实现不同版本(iOS6前后)的屏幕旋转控制。针对iOS6及之后版本,采用supportedInterfaceOrientations与shouldAutorotate方法;对于iOS6之前的版本,则使用shouldAutorotateToInterfaceOrientation方法。
681

被折叠的 条评论
为什么被折叠?



