从iOS 3.2开始,MPMoviePlayerController类允许在视图层次结构中嵌入电影。 现在我遇到了这个问题:我通过放置MPMoviePlayerController的一个实例来创建我的肖像视图。当用户触摸“全屏”按钮时,该视图进入全屏模式,但视图保持纵向。当用户旋转设备时,全屏电影视图不会自动旋转,因为我的应用禁止横向界面方向。 因此,为了允许电影播放器全屏视图的自动旋转,我改变了我的视图控制器shouldAutorotateToInterfaceOrientation:如果 - 且仅当 - 如果 - 电影播放器处于全屏模式时才返回YES风景。 这很好地工作:当用户进入全屏,然后旋转到风景时,播放器会自动旋转到横向并填充整个屏幕。MPMoviePlayerController重定向肖像到风景并返回到肖像(iOS 4.1)
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
if(UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
return(YES);
}
if(UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
return([movieController isFullscreen]);
}
return(NO);
}
现在问题出现时,当我在全屏视图中触摸“完成”按钮,同时保持在横向。全屏关闭,然后我看到的是我的原始视图自动旋转:但我不希望这种自动旋转。
的部分,但不能接受的解决办法,就是要听“MPMoviePlayerDidExitFullscreenNotification”,如果接口旋转为横向,力重新定向到使用无证和私有函数:
[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait]
该作品但由于禁止使用此方法,因此不可接受。
我试图强制使用[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]
的方向,但因为我在选项卡栏中这不起作用(UITabBar保持横向大小)。
感谢您的帮助
您是否找到解决方案?我处于相同的情况,我找不到解决方案。 – klefevre 2013-04-18 09:08:03
理论上用iOS6引入的新方法来管理定位,这个问题可以通过直接设置每个视图控制器方向来解决。这可以通过使用向每个视图控制器请求方向权限的新方法来完成。 – viggio24 2013-04-18 13:08:34