在iOS 8上,我遇到了一种关于导航栏和方向变化的奇怪行为。
我有一个导航控制器,它报告支持界面方向
然后,我启动了一个模态视图控制器的演示,该控制器仅支持
iOS 7不表现出这种行为。我错过了什么?我想恢复旧的行为。
以下是上述简单示例的完整代码:
在一个更加复杂的设置中,当呈现竖屏模态时,导航控制器中包含的UIWebView中的文本也会被放大。但是在关闭模态窗口时,文本不会恢复到原始大小。
我有一个导航控制器,它报告支持界面方向
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中的文本也会被放大。但是在关闭模态窗口时,文本不会恢复到原始大小。