关于在使用笔尖文件时支持iPhone 5和向后兼容 [英] About supporting iPhone 5 when using nib files and backwards compatibility

查看:90
本文介绍了关于在使用笔尖文件时支持iPhone 5和向后兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找有关此问题的Apple文档和帖子,但是由于我发现的大多数信息都与情节提要和自动布局功能有关,因此我没有明确说明应该如何处理.我使用的是nib文件而不是故事板,此外,我还需要支持iOS 5+,所以我不能使用自动布局.我正在使用Xcode 4.6.3,并且已经观察到,在IB中,转到视图的属性"检查器>模拟度量",您可以选择其大小("Retina 3.5全屏","Retina 4全屏" ... ).现在,我将此参数设置为"None",是否应该为每个屏幕尺寸设置一个笔尖文件,并以编程方式检测当前设备是iPhone 5还是另一部手机(类似于我为Universal应用程序中支持iPad所做的操作)?如果没有,鉴于我的特殊条件,我应该如何管理对iPhone 5的支持?

I've been looking for Apple's documentation and posts regarding this issue, but I didn't make it clear how should I deal with this, since most of information I found is about storyboards and autolayout feature. I'm using nib files instead of storyboards, and in addition I need to support iOS 5+, so I can't use autolayout. I'm using Xcode 4.6.3 and I've observed that, in IB, going to the view's Attributes inspector > Simulated Metrics, you can choose its size ("Retina 3.5 Full Screen", "Retina 4 Full Screen"...). Right now, I have this parameter set to "None", should I have one nib file per each screen size and detect programmatically if current device is iPhone 5 or another phone (similarly to what I do for supporting iPad in Universal app)? If not, how should I manage this iPhone 5 support, given my particular conditions?

谢谢!

推荐答案

1.添加"Default-568h@2x.png"图片,使用此图片,当应用启动时将使用iPhone5屏幕大小,如果不使用,则在应用启动时使用iPhone4S的屏幕尺寸

1.Add "Default-568h@2x.png" image,with this,when app launch will use iPhone5 screen size,if not, when app launch will use iPhone4S screen size

2.设置自定义ViewController的视图autoresizingMask属性

2.Set your Custom ViewController's view autoresizingMask property

例如:self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

eg: self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

3.如果自定义ViewController的子视图包含UITableView或UIScrollView,则设置此子视图的autoresizingMask属性

3.If your Custom ViewController's subviews include UITableView or UIScrollView, set this subview's autoresizingMask property

例如:self.aScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

eg:self.aScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

这就是您需要做的所有事情.

That's all you need do.

这篇关于关于在使用笔尖文件时支持iPhone 5和向后兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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