补充: 我看到我的问题经常在没有赞成的情况下被查看,所以我决定你们没有得到你搜索的内容.重定向到有关如何处理iOS6中的方向更改的答案非常好的问题
方向变化的具体要求: 限制轮换
欢迎Upvotes :)
我已经从Master Detail模板创建了一个新项目,并尝试以横向方向启动它.如你所知
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
方法已弃用,我们必须使用
- (NSUInteger)supportedInterfaceOrientations
和/或
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
这是我的代码:
- (NSUInteger)supportedInterfaceOrientations {
NSLog(@"supported called");
return UIInterfaceOrientationMaskAll;//Which is actually a default value
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
NSLog(@" preferred called");//This method is never called. WHY?
return UIInterfaceOrientationLandscapeRight;
}
Run Code Online (Sandbox Code Playgroud)
正如你所看到的那样,我试图在首选方法中返回横向,但它永远不会被调用.ps文档说明:
讨论系统在全屏显示视图控制器时调用此方法.当视图控制器支持两个或更多方向时,您可以实现此方法,但内容在其中一个方向中最佳.
如果视图控制器实现此方法,则在显示时,其视图将以首选方向显示(尽管稍后可以将其旋转到另一个受支持的旋转).如果未实现此方法,系统将使用状态栏的当前方向显示视图控制器.
所以,问题是:为什么永远不会调用prefferredOrientation方法?我们应该如何在不同的控制器中处理不同的方向?谢谢!PS不会将问题标记为重复.我调查了所有类似的问题,他们没有我的答案.
面向IPad启动横向应用的一个问题.我开发了IPhone应用程序,后来我移植到IPad.
我已经在info.plist中设置了关于方向的设置
[ UISupportedInterfaceOrientations~ipad ] to support all orientation UIInterfaceOrientationPortrait , UIInterfaceOrientationPortraitUpsideDown , UIInterfaceOrientationLandscapeLeft , UIInterfaceOrientationLandscapeRight.
Run Code Online (Sandbox Code Playgroud)
但是当我在横向模式下启动IPad应用程序时,它总是以potrait模式启动.
沿着这个
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{ return YES; }
Run Code Online (Sandbox Code Playgroud)
帮助我,如果我错过了这个...
谢谢,
萨加尔