小编the*_*ulf的帖子

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"; …
Run Code Online (Sandbox Code Playgroud)

uiviewcontroller uinavigationcontroller presentviewcontroller ios8

9
推荐指数
1
解决办法
1667
查看次数