8
在iOS 8上,我对导航栏和方向更改有奇怪的行为。iOS 8:在纵向上呈现模态视图控制器会导致底层横向导航控制器导航栏的大小调整
我有一个导航控制器,它报告支持的接口方向UIInterfaceOrientationMaskLandscapeRight
。导航栏有横向的预期高度(可惜我无权发布截图)。
然后我发起一个视图控制器的模态演示,该控制器只支持UIInterfaceOrientationMaskPortrait
。当演示动画开始时,底层导航控制器的度量标准似乎会更改为肖像演示文稿,因为导航栏的高度会增加到其纵向大小,如上所述。
iOS 7不显示此行为。我错过了什么?我想恢复旧的行为。
这里是上面的简单例子的全码:
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
DOGButtonViewController *root = [DOGButtonViewController new];
DOGOrientedNavigationController *navi = [[DOGOrientedNavigationController alloc] initWithRootViewController:root];
navi.allowedInterfaceOrientations = UIInterfaceOrientationMaskLandscapeRight;
self.window.rootViewController = navi;
[self.window makeKeyAndVisible];
return YES;
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortrait;
}
@end
@implementation DOGOrientedNavigationController
- (NSUInteger)supportedInterfaceOrientations
{
return self.allowedInterfaceOrientations;
}
@end
@implementation DOGButtonViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Button View Controller";
}
- (BOOL)prefersStatusBarHidden
{
return YES;
}
- (IBAction)buttonClicked:(id)sender
{
DOGPortraitViewController *vc = [DOGPortraitViewController new];
[self presentViewController:vc animated:YES completion:nil];
}
@end
@implementation DOGPortraitViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Portrait Title";
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (IBAction)buttonClicked:(id)sender
{
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
- (BOOL)prefersStatusBarHidden
{
return YES;
}
@end
在一个更复杂的设置我也遇到包含在导航控制器一个UIWebView文本呈现所述肖像模式时被放大。在解除模式时,文本不会调整为原始大小。
你设法找到解决这个删除此屏幕截图?我遇到同样的事情 – 2014-10-03 20:17:43
不幸的是,但我会在即将到来的日子里研究这一点。 – thewulf 2014-10-06 07:25:28
这里也有类似的问题。它看起来像呈现视图控制器也旋转(虽然它不应该) – Carlos 2015-05-05 18:01:25