我正在使用xcdYoutubeVideoViewController,它是MPMoviePlayerController的子类。我的申请是纵向的。要启动电影播放器,我正在这样做:
UINavigationController *navBarController = (UINavigationController*)[[[UIApplication sharedApplication] keyWindow] rootViewController] ;
[navBarController presentMoviePlayerViewControllerAnimated:vc];
其中vc是XCDYouTubeVideoPlayerViewController的实例。如何仅在此视图中允许旋转,并在Movieplayer中按“完成”按钮将应用程序恢复为纵向?
最佳答案
您应该重写:每个视图控制器中的-(BOOL) shouldAutorotate
。如果您希望该视图控制器旋转NO,则返回YES。确保检查情节提要设置上支持的方向。
更新:在显示播放器的父控制器中,尝试以下操作:
- (BOOL)shouldAutorotate
{
// 1. check if the parent presentedViewController is the nav containing the player
// 2. if yes, return YES, NO otherwise
}
如果应用程序根控制器是导航控制器,则子类
UINavigationViewController
并使用该类在App Delegate中创建应用程序根视图控制器@implementation ANavigationViewControllerSubClass
- (BOOL)shouldAutorotate
{
return [self.topViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.topViewController preferredInterfaceOrientationForPresentation];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return [self.topViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.topViewController preferredInterfaceOrientationForPresentation];
}
关于ios - 如何仅旋转子类化的mpmovieplayer Controller 并使其他 View 固定为人像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25638064/