我有一个应用程序,我有一个UINavigationController子类作为我的rootViewController.我有一个UITableViewController允许用户编辑一些设置,它应该始终处于纵向模式.将MoviePlayer组件推送到导航控制器后,我的应用程序还需要支持所有其他方向.
该UITableViewController子类有此实现supportedInterfaceOrientations的:
- (NSUInteger)supportedInterfaceOrientations {
LLog();
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
logging命令告诉我实际调用它.
问题是没有遵守返回值,即当我转动设备时屏幕转向横向.
如何使设置视图始终以纵向显示,但允许更改视频查看器的方向?
更多信息:我的UINavigationController子类不会覆盖shouldAutorotate或supportedInterfaceOrientations.我没有实施
- (NSUInteger)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window
Run Code Online (Sandbox Code Playgroud)
我的AppDelegate中的方法,我已启用目标摘要中的所有方向.
在用户完成观看视频(允许以横向模式观看)之前,我已经使用此代码强制将方向更改回纵向,然后将视频视图控制器从导航控制器上弹出:
//set statusbar to the desired rotation position
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];
//present/dismiss viewcontroller in order to activate rotating.
UIViewController *mVC = [[[UIViewController alloc] init] autorelease];
[self presentModalViewController:mVC animated:NO];
[self dismissModalViewControllerAnimated:NO];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
Run Code Online (Sandbox Code Playgroud)
这完美地工作直到iOS 5.1.1.我甚至试图在另一篇文章中阅读后使用新的现有/解除方法,现在应该使用这些方法:
[self presentViewController:mVC animated:NO completion:NULL];
[self dismissViewControllerAnimated:NO completion:NULL];
Run Code Online (Sandbox Code Playgroud)
问题是它根本不起作用.将视频查看器旋转到横向然后弹出后,我的设置视图(表格视图控制器)返回,但也处于横向模式.
我甚至试过过这里的小费
"该setStatusBarOrientation:animated:方法并未完全弃用.但是,现在只有当supportedInterfaceOrientations最顶层的全屏视图控制器的方法返回0时,它才有效.这使得确保状态栏方向与调用者手中一致的责任."
所以,我尝试了设置标志,强制supportedInterfaceOrientations到return 0(调用上面的第一个代码块之前),但它也不起作用.
有人有解决方案吗?感谢您的时间和精力.
cocoa-touch objective-c uiinterfaceorientation autorotate ios6