-->

About supporting iPhone 5 when using nib files and

2019-06-10 10:40发布

问题:

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?

Thanks!

回答1:

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.Set your Custom ViewController's view autoresizingMask property

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

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

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

That's all you need do.