iOS單個ViewController支持橫屏,其他全豎屏方法
作者:佚名
如果項目中用了navigationViewController, 那么就應該新建一個uinavigationViewController的子類,然后在這個類里面寫上下面的代碼,在使用的時候就用自定義的這個navCtr, 就是說需要在根視圖里面控制
如果項目中用了navigationViewController, 那么就應該新建一個uinavigationViewController的子類,然后在這個類里面寫上下面的代碼,在使用的時候就用自定義的這個navCtr, 就是說需要在根視圖里面控制
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
- {
- return toInterfaceOrientation != UIDeviceOrientationPortraitUpsideDown;
- }
- - (BOOL)shouldAutorotate
- {
- if ([self.topViewController isKindOfClass:[AddMovieViewController class]]) { // 如果是這個 vc 則支持自動旋轉
- return YES;
- }
- return NO;
- }
- - (NSUInteger)supportedInterfaceOrientations
- {
- return UIInterfaceOrientationMaskAllButUpsideDown;
- }
責任編輯:閆佳明
來源:
apkbus