【问题标题】:navigaiton bar frame is wrong when a custom window displaying显示自定义窗口时导航栏框架错误
【发布时间】:2020-08-18 11:46:12
【问题描述】:

我有一个新的自定义 UIWindow 来显示仅支持的 fullSrceen ViewController UIInterfaceOrientationMaskLandscapeLeft

- (BOOL)shouldAutorotate {
    return YES;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationLandscapeLeft;
}

一个按钮点击它打开“set window.hidden = NO”

- (void)show {
    UIWindowScene *scence = [UIApplicationsharedApplication].connectedScenes.allObjects.firstObject;
    self.window = [[CustomWindow alloc]initWithWindowScene:scence];
    CustomViewController *vc = [[CustomViewController alloc]init];;
    self.window.rootViewController = vc;
    self.window.hidden = NO;
    self.window.windowLevel = 2;
    [self.window makeKeyAndVisible];
}

和一个按钮来关闭“set window.hidden = YES”,

- (void)close {
    self.window.hidden = YES;
    self.window = nil;
}

一切正常,但是当我打开窗口并回到后台,然后我进入前台并关闭窗口时,navigationbar 不在位置。

Portrait state

Landscape state

background state

navigation bar wrong position

code is here

【问题讨论】:

  • 为什么要创建一个新帐户和问题而不是编辑和修复your previous one

标签: ios objective-c swift uinavigationcontroller


【解决方案1】:

我已经修复了这个错误。 在显示自定义窗口之前使用 presentViewController 一个临时 vc。

- (IBAction)showApp:(id)sender {
    UIViewController *vc = [[UIViewController alloc]init];
    vc.modalPresentationStyle = UIModalPresentationFullScreen;
    self.tempVc = vc;
    [self presentViewController:vc animated:NO completion:^{
        [self.app show];
    }];
}

【讨论】:

    猜你喜欢
    • 2021-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多