这个问题的实际标题太长了,我无法适应:
启动一个应用程序,其根视图控制器仅支持纵向,但在主屏幕处于横向时支持iPhone 6Plus上的横向,会导致应用程序的窗口处于横向但设备处于纵向的边缘状态。
简而言之,它看起来像这样:
当它看起来像这样的时候:
再现的步骤:
运行orientations.
supportedInterfaceOrientations
.
6 Plus).
UIInterfaceOrientationMaskPortrait
orientations.除了完全禁用横向之外,我想不出任何其他方法来强制使用纵向,但我不能这样做:我们的web浏览器模式视图控制器需要横向。
我甚至尝试对UITabBarController进行子类化并覆盖supportedInterfaceOrientations以返回仅用于肖像的掩码,但这(即使使用上面的所有其他步骤)也不能解决问题。
发布于 2014-09-24 03:22:16
当使用UITabBarController作为根视图控制器时,这似乎是iOS 8中的一个错误。一种解决方法是使用一个普通的UIViewController作为根视图控制器。这个普通的视图控制器将作为标签栏控制器的父视图控制器:
///------------------------
/// Portrait-Only Container
///------------------------
@interface PortraitOnlyContainerViewController : UIViewController
@end
@implementation PortraitOnlyContainerViewController
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
@end
// Elsewhere, in app did finish launching ...
PortraitOnlyContainerViewController *container = nil;
container = [[PortraitOnlyContainerViewController alloc]
initWithNibName:nil
bundle:nil];
[container addChildViewController:self.tabBarController];
self.tabBarController.view.frame = container.view.bounds;
[container.view addSubview:self.tabBarController.view];
[self.tabBarController didMoveToParentViewController:container];
[self.window setRootViewController:container];
发布于 2014-10-28 06:41:26
当我在iPhone 6Plus上启动我们的应用程序时,也遇到了同样的问题。
我们的修复方法是通过项目设置从plist中删除横向支持的界面方向:
并在app委托中实现application:supportedInterfaceOrientationsForWindow::
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
显然,plist中的信息是指定您的应用程序可以启动的方向。
发布于 2014-10-01 12:06:27
设置UIApplication
的statusBarOrientation
似乎对我很有效。我把它放在app委托的application:didFinishLaunchingWithOptions:
方法中。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
application.statusBarOrientation = UIInterfaceOrientationPortrait;
// the rest of the method
}
https://stackoverflow.com/questions/26003086
复制相似问题