我有一个新的自定义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
处于偏离位置的状态。
我已经修复了这个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];
}];
}