在更新到iOS 13之前,我有一些代码可以正常工作,现在它无法正常工作,我需要帮助修复它。我有一个横向视图,可以推动人像视图。在更新到iOS 13之后,推送视图不再在iPhone上显示为纵向,而是横向。如何强制将其设为纵向?
我在这里寻找了类似的问题,但是它们都是古老的,并且似乎是iOS 13特有的。请不要告诉我重新设计界面-我已经尝试询问客户,并被告知他们希望保留当前行为。 。(由于基础架构的需要,视图位于单独的情节提要中。)
希望我错过了一些简单的解决方案。谢谢!
该项目文件支持除倒置人像外的所有方向。
一个显示该问题的简化项目可在https://github.com/dpreuitt/testPortrait.git上公开获得。
这是一些代码:
LandscapeViewController:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (BOOL) shouldAutorotate {
return YES;
}
- (UIInterfaceOrientationMask) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeLeft;
}
- (IBAction)pushPortrait:(id)sender
{
UIStoryboard *portraitStoryboard = [UIStoryboard storyboardWithName:@"Portrait" bundle:nil];
PortraitViewController* loginController = [portraitStoryboard instantiateViewControllerWithIdentifier:@"PortraitVC"];
dispatch_async(dispatch_get_main_queue(), ^(){
[self presentViewController:loginController animated:YES completion:nil];
});
}
纵向视图控制器:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (BOOL) shouldAutorotate {
return YES;
}
- (UIInterfaceOrientationMask) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
(在整个项目中,要推送的代码可能是从后台线程触发的,因此需要“ get_main_queue”)
该示例项目具有带按钮的横向视图。单击该按钮时,应该出现一个纵向的视图控制器,但不幸的是在横向模式下出现。
将人像故事板上的UIModalPresentationStyle设置为FullScreen即可正常工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句