如果需要旋轉(zhuǎn)的ViewController 使用了UINavigationController,對(duì)UINavigationController進(jìn)行如下擴(kuò)展
@implementation UINavigationController(shouldAutorotate)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ return (interfaceOrientation == UIInterfaceOrientationPortrait);}
- (BOOL)shouldAutorotate{ return self.topViewController.shouldAutorotate;}
- (NSUInteger)supportedInterfaceOrientations{ return self.topViewController.supportedInterfaceOrientations;}@end
需要旋轉(zhuǎn)的ViewController設(shè)置
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ return YES;}- (BOOL)shouldAutorotate{ return YES;}- (NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskAll;}
其他不需要旋轉(zhuǎn)的 ViewController設(shè)置,建議添加BaseViewController統(tǒng)一控制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ return (interfaceOrientation == UIInterfaceOrientationPortrait);}- (BOOL)shouldAutorotate{ return NO;}- (NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationPortrait;}
|
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注