0

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!

AppsDev
  • 12,319
  • 23
  • 93
  • 186
  • The way I do this is, I create view for iPhone4 and use Autoresize property to adjust controls for iPhone5. – iphonic Jul 24 '13 at 04:23

1 Answers1

0

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.

timothy lau
  • 386
  • 2
  • 2
  • Thanks! So, should I keep the view's Simulated metrics to "None", or should I set them to "Freeform"? – AppsDev Jul 24 '13 at 03:12
  • Should be none@AppsDev – timothy lau Jul 24 '13 at 03:27
  • You have it set to either iPhone5, iPhone4, or none. If you set it to iPhone5 size, you just have to keep in mind it will shrink on an iPhone4 when laying out your content. Same is true if you set the IB view size to iPhone4, just know it will stretch when on a 5. – random Jul 24 '13 at 03:49
  • @random it looks like that only works for views with tables or another scrollable content... I have a view with buttons at the bottom of the screen. If I set the view to iPhone 5 size in IB, then in other iPhone devices the buttons are "out" of the screen, and setting iPhone 4 size in IB results in not having the buttons at the bottom of the screen in iPhone 5... how should I handle this kind of things? – AppsDev Jul 31 '13 at 13:38
  • @AppsDev Of course it will work with UIScrollView and it's subclasses (UITableView) because scrollview frame can scale independently of its content size (the size of stuff within the scroll view). You need to adjust the autoresizing mask/autolayout constraints of the buttons in InterfaceBuilder so that they now how to stay on screen for different sizes. Same principle for setting the autoresizing/autolayout of IB elements to deal with orientation changes. – random Jul 31 '13 at 16:28
  • @random Ok, thanks! And if I want to change a background image according to the screen size? What should I do? – AppsDev Jul 31 '13 at 16:57
  • @AppsDev The change the actual image itself? As in go from an image of a cat to a dog? Or just scale the image to fit the size? To go from cat to dog just check the size of screen when your view loads and set the image accordingly. See this: http://stackoverflow.com/questions/12398798/ios-6-distinguishing-between-iphone-5-and-other-devices – random Jul 31 '13 at 17:05
  • @AppsDev If you just want it to scale then adjust the autoresizing/autolayouts to that it scales to fill the screen. – random Jul 31 '13 at 17:05