横向模式下的 iPhone 应用程序,2008 系统 [英] iPhone app in landscape mode, 2008 systems

查看:355
本文介绍了横向模式下的 iPhone 应用程序,2008 系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请注意,这个问题来自 2008 年,现在仅具有历史意义.

Please note that this question is from 2008 and now is of only historic interest.

创建一个从一开始就以横向模式运行的 iPhone 应用程序的最佳方法是什么,无论设备的位置如何?

What's the best way to create an iPhone application that runs in landscape mode from the start, regardless of the position of the device?

以编程方式和使用 Interface Builder.

Both programmatically and using the Interface Builder.

推荐答案

仅限历史答案.非常过时.

请注意,这个答案现在已经过时了/

Historic answer only. Spectacularly out of date.

Please note that this answer is now hugely out of date/

这个答案只是历史上的好奇.

令人振奋的消息!正如下面 Andrew 所发现的,Apple 已在 4.0+ 中修复了此问题.

Exciting news! As discovered by Andrew below, this problem has been fixed by Apple in 4.0+.

似乎不再需要在每个视图上强制调整视图的大小,并且景观仅在第一次工作"的具体严重问题已解决.

It would appear it is NO longer necessary to force the size of the view on every view, and the specific serious problem of landscape "only working the first time" has been resolved.

截至 2011 年 4 月,无法测试甚至构建低于 4.0 的任何东西,所以这个问题纯粹是历史上的好奇.这么长时间给开发者带来了多大的麻烦,真是不可思议!

As of April 2011, it is not possible to test or even build anything below 4.0, so the question is purely a historic curiosity. It's incredible how much trouble it caused developers for so long!

这是最初的讨论和解决方案.现在这完全无关紧要,因为这些系统甚至无法运行.

Here is the original discussion and solution. This is utterly irrelevant now, as these systems are not even operable.

要完全完成这项工作是极其困难的——至少存在三个问题/错误.

It is EXTREMELY DIFFICULT to make this work fully -- there are at least three problems/bugs at play.

试试这个.. 界面构建器景观设计

请特别注意,并且您需要在任何地方正确使用 shouldAutorotateToInterfaceOrientation" 这意味着无处不在,您的所有全屏视图.

Note in particular that where it says "and you need to use shouldAutorotateToInterfaceOrientation properly everywhere" it means everywhere, all your fullscreen views.

希望它对这场噩梦有所帮助!

Hope it helps in this nightmare!

这里要提醒一下手头的另一个众所周知的问题:如果您尝试在 MORE THAN ONE 视图(所有横向)之间切换,它根本不起作用.记住这一点很重要,否则你会在这个问题上浪费几天的时间.这实际上是不可能的.这是 iOS 平台上最大的已知漏洞.从字面上看,没有办法让硬件使您加载的第二个视图成为风景.烦人但简单的解决方法,你必须做的是,拥有一个微不足道的主 UIViewController,它什么也不做,只是坐在那里让你在视图之间切换.

An important reminder of the ADDITIONAL well-known problem at hand here: if you are trying to swap between MORE THAN ONE view (all landscape), IT SIMPLY DOES NOT WORK. It is essential to remember this or you will waste days on the problem. It is literally NOT POSSIBLE. It is the biggest open, known, bug on the iOS platform. There is literally no way to make the hardware make the second view you load, be landscape. The annoying but simple workaround, and what you must do, is have a trivial master UIViewController that does nothing but sit there and let you swap between your views.

也就是说,在 iOS 中因为一个重大的已知 bug:

In other words, in iOS because of a major know bug:

[window addSubview:happyThing.view];
[window makeKeyAndVisible];

您只能这样做一次.稍后,如果您尝试删除 happyThing.view,而是将 newThing.view 放在那里,它不起作用 - 就是这样.机器永远不会将视图旋转为横向.没有任何技巧可以修复,即使 Apple 也无法使其正常工作.您必须采用的解决方法是拥有一个整体 UIViewController,它只是坐在那里并只保存您的各种视图(happyThing、newThing 等).希望对您有所帮助!

You can do that only once. Later, if you try to remove happyThing.view, and instead put in there newThing.view, IT DOES NOT WORK - AND THAT'S THAT. The machine will never rotate the view to landscape. There is no trick fix, even Apple cannot make it work. The workaround you must adopt is having an overall UIViewController that simply sits there and just holds your various views (happyThing, newThing, etc). Hope it helps!

这篇关于横向模式下的 iPhone 应用程序,2008 系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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