meg*_*ara 0 xcode rotation screen-orientation ios landscape-portrait
我有一个带故事板的iOS应用程序.我希望我的上一个viewcontroller始终处于纵向模式.我一直在读书,从那以后我发现了
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
Run Code Online (Sandbox Code Playgroud)
不推荐使用我应该使用其他方法
-(BOOL)shouldAutorotate
-(NSInteger)supportedInterfaceOrientations
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
Run Code Online (Sandbox Code Playgroud)
但我已经尝试了很多这种方法的组合,我无法做到这一点.所以请有人能告诉我正确的方法吗?
由于您的UIViewController嵌入在UINavigationController中,因此除非您自己转发呼叫,否则永远不会被调用.(在我看来,UINavigationController有点瑕疵)
子类UINavigationController是这样的:
@interface RotationAwareNavigationController : UINavigationController
@end
@implementation RotationAwareNavigationController
-(NSUInteger)supportedInterfaceOrientations {
UIViewController *top = self.topViewController;
return top.supportedInterfaceOrientations;
}
-(BOOL)shouldAutorotate {
UIViewController *top = self.topViewController;
return [top shouldAutorotate];
}
@end
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2304 次 |
最近记录: |