xcode – iOS6中的纵向和横向模式
发布时间:2020-12-14 19:36:04 所属栏目:百科 来源:网络整理
导读:将我的应用程序更新为iOS6标准时,纵向/横向消失了.当我使用 Xcode 3构建时,Ir工作得很好.但是现在使用最新的Xcode和最新的SDK,旋转消失了,它始终处于纵向模式.无论我在“支持的界面方向”中加入什么.我以前用来获得旋转的代码似乎根本没有效果. 我有这些台词
将我的应用程序更新为iOS6标准时,纵向/横向消失了.当我使用
Xcode 3构建时,Ir工作得很好.但是现在使用最新的Xcode和最新的SDK,旋转消失了,它始终处于纵向模式.无论我在“支持的界面方向”中加入什么.我以前用来获得旋转的代码似乎根本没有效果.
我有这些台词. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { switch (toInterfaceOrientation) { case UIInterfaceOrientationPortrait: case UIInterfaceOrientationLandscapeLeft: case UIInterfaceOrientationLandscapeRight: return YES; default: return NO; } } 我如何更改以及如何更改以使其再次运行? 解决方法
首先,在AppDelegate中,写下这个.这是非常重要的
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return (UIInterfaceOrientationMaskAll); } 然后,对于只需要PORTRAIT模式的UIViewControllers,编写这些函数 - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return (UIInterfaceOrientationMaskPortrait); } 对于也需要LANDSCAPE的UIViewControllers,将掩码更改为All. - (NSUInteger)supportedInterfaceOrientations { return (UIInterfaceOrientationMaskAllButUpsideDown); //OR return (UIInterfaceOrientationMaskAll); } 现在,如果要在Orientation更改时进行一些更改,请使用此功能. - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { } 编辑: 很大程度上取决于你的UIViewController嵌入哪个控制器. 例如,如果它在UINavigationController中,那么您可能需要将UINavigationController子类化为覆盖这样的方向方法. 子类化UINavigationController(层次结构的顶层视图控制器将控制方向.)确实将其设置为self.window.rootViewController. - (BOOL)shouldAutorotate { return self.topViewController.shouldAutorotate; } - (NSUInteger)supportedInterfaceOrientations { return self.topViewController.supportedInterfaceOrientations; } 从iOS 6开始,UINavigationController不会要求其UIVIewControllers提供方向支持.因此我们需要将其子类化. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |