在 xcode 中开发全屏 4 英寸应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12402803/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Developing fullscreen 4inch app in xcode
提问by k06a
Possible Duplicate:
How do I support the taller iPhone 5 screen size?
可能的重复:
我如何支持更高的 iPhone 5 屏幕尺寸?
How to make my app 4inch-ready? My app in iOS6GM simulator looks not 4inch-sized. Is there any option in xcode to use all 4 inches?
如何让我的应用程序支持 4 英寸?我在 iOS6GM 模拟器中的应用看起来不是 4 英寸大小。xcode 中是否有任何选项可以使用所有 4 英寸?
回答by Sverrisson
Some users have reported that it was fixed after adding the startup image [email protected]
(see below).
For updating to iPhone5 I did the following:
一些用户报告说在添加启动图像后它被修复了[email protected]
(见下文)。为了更新到 iPhone5,我做了以下事情:
Autorotation is changing in iOS 6. In iOS 6, the shouldAutorotateToInterfaceOrientation:
method of UIViewController is deprecated. In its place, you should use the supportedInterfaceOrientationsForWindow:
and shouldAutorotate
methods. Thus, I added these new methods (and kept the old for iOS 5 compatibility):
Autorotation 在 iOS 6 中发生了变化。在 iOS 6 中,shouldAutorotateToInterfaceOrientation:
不推荐使用 UIViewController的方法。取而代之的是,您应该使用supportedInterfaceOrientationsForWindow:
和shouldAutorotate
方法。因此,我添加了这些新方法(并保留了旧的以兼容 iOS 5):
-(BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
- Then I fixed the autolayout for views that needed it.
- Copied images from the simulator for startup view and views for the iTunes store into PhotoShop and exported them as png files.
- The name of the default image is: [email protected] the size is 640 x 1136 and the screen size 320 x 568.
- I have dropped backward compatibility for iOS 4. The reason is that this new Xcode does not support armv6 code any more. Thus, all devices that I am able to support now (running armv7) can be upgraded to iOS 5.
- 然后我修复了需要它的视图的自动布局。
- 将模拟器中用于启动视图和 iTunes 商店视图的图像复制到 PhotoShop 中,并将它们导出为 png 文件。
- 默认图片名称为:[email protected] 尺寸为 640 x 1136,屏幕尺寸为 320 x 568。
- 我已经放弃了对 iOS 4 的向后兼容性。原因是这个新的 Xcode 不再支持 armv6 代码。因此,我现在能够支持的所有设备(运行 armv7)都可以升级到 iOS 5。
That was all but just remember to test the autorotation in iOS 5 and iOS 6 because of the changes in rotation.
由于旋转的变化,请记住在 iOS 5 和 iOS 6 中测试自动旋转。
回答by Kjuly
Before iPhone 5 release, I just use
在 iPhone 5 发布之前,我只是使用
#define kViewHeight 460.f // or 480.f if you don't have a status bar
#define kViewWidth 320.f
But now, I would like to use
但现在,我想用
#define kViewHeight CGRectGetHeight([UIScreen mainScreen].applicationFrame)
#define kViewWidth CGRectGetWidth([UIScreen mainScreen].applicationFrame)
instead.
反而。
But I'm not sure whether it is a good solution. As you see, you would dispatch CGRectGetHeight([UIScreen mainScreen].applicationFrame)
every where you use kViewHeight
. I've tried to use
但我不确定这是否是一个好的解决方案。如您所见,您将在CGRectGetHeight([UIScreen mainScreen].applicationFrame)
每个使用kViewHeight
. 我试过用
extern float kViewHeight; // in .h
float kViewHeight = CGRectGetHeight([UIScreen mainScreen].applicationFrame) // in .m
but failed with a compile error.
但因编译错误而失败。
Though it works well, I think there must be a better workaround. ;)
虽然效果很好,但我认为必须有更好的解决方法。;)