即使设备在 objective c 中水平旋转,如何始终以纵向模式加载 UIViewController?
How to always load a UIViewController in portrait mode even if the device is rotated horizontally in objective c?
我的 UIViewController 处于纵向模式,当我转到另一个 UIViewController 并水平旋转设备然后返回到之前的 UIViewController 时,它的视图全乱了。我的应用程序支持设备的每个方向,我实现了方法:
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
但是我无法解决这个问题。如何始终以纵向加载 UIViewContoller,而不管设备方向和先前加载的 UIViewContoller 的方向?感谢您的回答和帮助。
我修好了。 :) 在 viewDidLoad 我放了这行代码:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
并添加方法:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotate {
return NO;
}
它工作正常。
我的 UIViewController 处于纵向模式,当我转到另一个 UIViewController 并水平旋转设备然后返回到之前的 UIViewController 时,它的视图全乱了。我的应用程序支持设备的每个方向,我实现了方法:
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
但是我无法解决这个问题。如何始终以纵向加载 UIViewContoller,而不管设备方向和先前加载的 UIViewContoller 的方向?感谢您的回答和帮助。
我修好了。 :) 在 viewDidLoad 我放了这行代码:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
并添加方法:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotate {
return NO;
}
它工作正常。