大佬教程收集整理的这篇文章主要介绍了ios – 如何在横向方向上推出通用的Xcode 5 app项目?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
控制台输出表示应用程序之后的窗口:didFinishLaunchingWithOptions:是:
{{0,0},{768,1024}}
我添加了一个标准系统按钮来查看ViewController,以说明应用程序是横向而不是纵向,但窗口是纵向的.
因为堆栈溢出具有白色背景,所以我在Photoshop中将右部分灰色着色,以便您可以看到它:
在应用程序中:didFinishLaunchingWithOptions:我将窗口涂成红色.显然不是横向的.
我已经尝试过所知道的所有技巧:
1)Info.plist包含UISupportedInterfaceOrientations键,其中包含:
UIInterfaceOrientationLandscapeLeft和UIInterfaceOrientationLandscapeRight
2)Info.plist包含UISupportedInterfaceOrientations~ipad键:
UIInterfaceOrientationLandscapeLeft和UIInterfaceOrientationLandscapeRight
3)Info.plist包含初始界面方向的UIInterfaceOrientation键:
UIInterfaceOrientationLandscapeRight
4)在xcode中单击项目,然后取消选中所有纵向选项,仅检查横向选项:
5)AppDelegate和ViewController都有:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape(interfaceOrientation); } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; } - (BOOL)shouldAutorotate { return YES; }
6)AppDelegate有:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; }
Xcode创建了两个故事板文件.我现在只在iPad上测试.一个是Main_iPad.storyboard,它显示了一个纵向的视图控制器.但它只是一个模拟的界面指标.改为景观,正如预期没有效果.
在应用程序启动期间,我检查UIScreen界限,它也显然是肖像,而不是横向:
CGRect screenBounds = [[UIScreen mainScreen] bounds]; // {{0,1024}}
如何使其在横向上启动并创建横向窗口?
@H_944_2@
我遇到了一个问题,因为我在视图控制器的initWithNibName:bundle中以编程方式创建了我的视图:无论出于何种原因,这样做会在纵向模式下定向新视图,而应用程序的其余部分正在运行横向.
我找到了两个解决这个问题的方法. 1)使用故事板而不是以编程方式创建视图或2)移动代码以从视图控制器的initWithNibName:bundle:方法创建视图,并将其放在视图控制器的-viewDidLoad:方法中,如下所示:
-(void)viewDidLoad { //Create your view progrAMMatically UIView *view = [[UIView alloc] initWithFrame:self.view.frame]; //Customize view [self.view addSubview:view]; }
这是我遇到类似问题的解决方案.虽然我认识到程序员可以通过各种方式使事情不能正常运行,但我希望这就是答案!
@H_944_2@ @H_944_2@以上是大佬教程为你收集整理的ios – 如何在横向方向上推出通用的Xcode 5 app项目?全部内容,希望文章能够帮你解决ios – 如何在横向方向上推出通用的Xcode 5 app项目?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。