大佬教程收集整理的这篇文章主要介绍了iphone – iOS 6.0中的界面方向,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
shouldAutorotate supportedInterfaceOrientations preferredInterfaceOrientationForPresentation
因为“shouldAutorotateToInterfaceOrientation”在iOS 6.0中已弃用。
谢谢。
// Override to allow orientations other than the default porTrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); }
在iOS 6中替换,以及相当于上述弃用的iOS 5方法:
- (BOOL) shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeRight; }
希望这可以帮助。
[编辑#1:添加我的UIViewController成功地开始在肖像模式在XCode 4.5在iPhone 6.0模拟器]
#import "FirstViewController.h" @interface FirstViewController () @end @implementation FirstViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundLeorNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundLeorNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } -(BOOL)shouldAutorotate { return NO; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationMaskPorTrait; }
[#edit 2:仅支持iOS 5和iOS 6的仅风景应用程序的示例代码]
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); } - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeLeft; }
以上是大佬教程为你收集整理的iphone – iOS 6.0中的界面方向全部内容,希望文章能够帮你解决iphone – iOS 6.0中的界面方向所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。