启动aplicaiton后iPad应用程序界面方向发生了变化 [英] iPad app interface orientation changed after launch of aplicaiton

查看:157
本文介绍了启动aplicaiton后iPad应用程序界面方向发生了变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发app。应用程序的方向是横向,但在app运行app界面方向后更改界面并旋转。以正确的方式(横向)启动屏幕显示。
我正在使用ios7应用程序是ios5的代码我认为有一些弃用的api问题,例如shouldAutorotateToInterfaceOrientation bot被调用因为在最新的ios中不再可用

i am working on app. the orientation of app is landscape but after app run interface orientation of app change the interface and rotate. splash screen display in correct way (landscape). i am using ios7 the app was code for ios5 i think there is some deprecated api issue e.g. shouldAutorotateToInterfaceOrientation bot called because this is no more available in latest ios

推荐答案

如果您希望我们的所有导航控制器都尊重顶视图控制器,您可以使用类别,所以你不必经历并改变一堆类名。

If you want all of our navigation controllers to respect the top view controller you can use a category so you don't have to go through and change a bunch of class names.

 @implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{
   return [[self.viewControllers lastObject] shouldAutorotate];
 } 

-(NSUInteger)supportedInterfaceOrientations
{
    return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject]     preferredInterfaceOrientationForPresentation];
}

@end

作为一些评论指出,这是对问题的快速解决方法。更好的解决方案是子类UINavigationController并将这些方法放在那里。子类也有助于支持6和7。

As a few of the comments point to, this is a quick fix to the problem. A better solution is subclass UINavigationController and put these methods there. A subclass also helps for supporting 6 and 7.

这篇关于启动aplicaiton后iPad应用程序界面方向发生了变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆