大佬教程收集整理的这篇文章主要介绍了xcode – iOS6中的纵向和横向模式,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { switch (toInterfaceOrientation) { case UIInterfaceOrientationPorTrait: case UIInterfaceOrientationLandscapeLeft: case UIInterfaceOrientationLandscapeRight: return YES; default: return NO; } }
我如何更改以及如何更改以使其再次运行?
- (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提供方向支持.因此我们需要将其子类化.
以上是大佬教程为你收集整理的xcode – iOS6中的纵向和横向模式全部内容,希望文章能够帮你解决xcode – iOS6中的纵向和横向模式所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。