如何在iOS 6中強制UIViewController面向肖像就像ShouldAutorotateToInterfaceOrientation在IOS 6中被廢棄,我使用它強制使用特定的視圖只限于肖像畫在iOS 6中,正確的方法是什么?這只適用于我的應用程序中的一個區域,所有其他視圖都可以旋轉。
3 回答

ABOUTYOU
TA貢獻1812條經驗 獲得超5個贊
@implementation UINavigationController (Rotation_IOS6)-(BOOL)shouldAutorotate{ return [[self.viewControllers lastObject] shouldAutorotate];}-(NSUInteger)supportedInterfaceOrientations{ return [[self.viewControllers lastObject] supportedInterfaceOrientations];}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];}@end

瀟瀟雨雨
TA貢獻1833條經驗 獲得超4個贊
UIApplication* application = [UIApplication sharedApplication];if (application.statusBarOrientation != UIInterfaceOrientationPortrait){ UIViewController *c = [[UIViewController alloc]init]; [self presentModalViewController:c animated:NO]; [self dismissModalViewControllerAnimated:NO];}
UIViewController
iOS 7的最新情況
UIApplication* application = [UIApplication sharedApplication];if (application.statusBarOrientation != UIInterfaceOrientationPortrait){ UIViewController *c = [[UIViewController alloc]init]; [c.view setBackgroundColor:[UIColor redColor]]; [self.navigationController presentViewController:c animated:NO completion:^{ [self.navigationController dismissViewControllerAnimated:YES completion:^{ }]; }];}
- 3 回答
- 0 關注
- 525 瀏覽
添加回答
舉報
0/150
提交
取消