当自定义窗口显示时,导航栏框架是错误的。

问题描述 投票:-2回答:1

我有一个新的自定义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];
}

和一个单一的buton来关闭 "set window.hidden = YES"。

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

所有的东西都很好用,但是当我打开窗口,回到背景,进入前景,然后关闭窗口,我就会发现,我的工作是很好的。navigationbar 处于偏离位置的状态。

人像状态

景观状态

背景国

导航栏错位

代码在此

ios objective-c swift uinavigationcontroller
1个回答
0
投票

我已经修复了这个bug.在显示自定义窗口之前使用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];
    }];
}
© www.soinside.com 2019 - 2024. All rights reserved.