[英]Device orientation in iOS 6 iphone issue
嗨我有一個基於Tab Bar的應用程序。 當我單擊第三個選項卡時,打開的視圖有一個tableview( AggregateMediaViewController
)。 在didSelect的行上,我使用MPMoviePlayerViewController
打開一個視頻。 我想在設備方向改變時設置此視頻的方向。 我創建了一個名為OrientationTabBarController
的UITabbarController
的子類:
@implementation OrientationTabBarControllerViewController
- (BOOL)shouldAutorotate {
NSLog(@"in shouldAutorotate tabbar is %@", self.viewControllers);
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
在appDidFifnishLaunching中:[window setRootViewController:tabBarController]; tabBarController是OrientationTabBarController的子類。
在AggregateMediaViewController中,我有以下代碼:
- (BOOL)shouldAutorotate
{
NSLog(@"in shouldAutorotate of media");
return YES;
}
-(NSInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}
但是當我運行應用程序時,方向不起作用:(請幫助
您需要子類化您的父控制器並添加UIViewController
旋轉方法。 在你的情況下,它是UITabBarController。 並在appDelegate中將其設置為rootViewController:
[self.window setRootViewController:_myTabBarController];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.