但到目前为止,这还不是很好。有什么办法吗?
@implementation UINavigationController
-(BOOL)shouldAutorotate
{
return UIInterfaceOrientationMaskPortrait;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}发布于 2017-01-03 21:36:11
您可以像在answer here中一样扩展UIScreen
并在其中执行
- (void)viewDidLayoutSubviews of UIViewController.类似于answer here中的内容
第一个链接中的代码与Objective-C中的代码类似:
- (UIInterfaceOrientation) orientation {
CGPoint p = [self.coordinateSpace convertPoint: CGPointZero toCoordinateSpace: self.fixedCoordinateSpace];
if (CGPointEqualToPoint(p, CGPointZero)) {
return UIInterfaceOrientationPortrait;
} else {
if (p.x != 0 && p.y != 0) {
return UIInterfaceOrientationPortraitUpsideDown;
} else {
if (p.x == 0 && p.y != 0) {
return UIInterfaceOrientationLandscapeLeft;
} else {
if (p.x != 0 && p.y == 0) {
return UIInterfaceOrientationLandscapeRight;
} else {
return UIInterfaceOrientationUnknown;
}
}
}
}
return UIInterfaceOrientationUnknown;}
https://stackoverflow.com/questions/33405432
复制相似问题