1

Just upgraded to the latest Xcode, and iOS6. When you create a new view controller with XIB it defaults to the iOS6 screen size, but you can change this manually to see how your app will look in iOS5.

My question is, are you meant to have two XIBs, one designed specifically for iOS5 and the other in iOS6; or do you use some kind of auto-sizing tool to handle everything?

Thanks.

jscs
  • 63,694
  • 13
  • 151
  • 195
zardon
  • 2,910
  • 6
  • 37
  • 58

1 Answers1

1

There has been lots of discussions around that in the Apple Dev Boards. My take on this:

If you can work with autoresizing or auto-layout, do not use multiple XIBs.

I bet in 99% of the views everybody uses, this is perfectly manageable. Table-views are a no-brainer, if you need a XIB for your table views only use one. If your view significantly differs for 3.5" and 4", use two XIBs. But try to avoid this by implementing a clever layoutSubviews routine.


Simple example for a parent view always aligning a subview bottomView at the bottom and full width:

- (void)layoutSubviews
{
    CGSize mySize = self.bounds.size;

    CGRect bottomFrame = bottomView.frame;
    bottomFrame.origin.y = mySize.height - bottomFrame.size.height;
    bottomFrame.size.width = mySize.width;
    bottomView.frame = bottomFrame;
}
Pascal
  • 16,846
  • 4
  • 60
  • 69
  • The only issue is that auto layout might not be supported by older versions. But I guess it'll do. Thanks – zardon Sep 26 '12 at 07:36
  • Yes that's true. I'm using autoresizing in simple and overriding `layoutSubviews` in more complicated cases, haven't yet used auto layout for the reason of backwards compatibility. – Pascal Sep 26 '12 at 14:28
  • It might be useful for other developers for an example regarding layoutSubviews, I found some documentation on http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html – zardon Sep 28 '12 at 17:01