0

I am new to orientation changes using XIBs.

I saw many questions like this, and this, but I can't seem to find simple solution here. I don't want to use any 3rd party framework that will do it, but would rather have step by step way of how should I redesign my XIBs and/or how should I create outlets. And what all should go inside XIB view code (the UIView derivative).

The view XIB don't have any outlets so far and I am not sure which outlets I should provide. Here is the structure of XIB:

enter image description here

Like the above, I would have 2-3 more XIBs from which I load views, all into same view controllers.

Again, I know how UIViewController can respond to orientation change (preferredInterfaceOrientationForPresentation and shouldAutorotateToInterfaceOrientation), but do not know how to load respective XIB with proper outlets upon each of such events. ,

Community
  • 1
  • 1
Nirav Bhatt
  • 6,940
  • 5
  • 45
  • 89

1 Answers1

2

This can be a pretty tricky task. You are correct that you add outlets to your views, and rearrange them programmatically in the view controller. That is a pretty daunting task, and takes a lot of time.

I would suggest using the auto layout tools provided in XCode to make this job easier, and help to make transitions look a lot smoother. Please check the links below:

Reloading the entire XIB every time the user changes orientation can be a good option if you are changing the contents of the view whenever the user changes orientation, not just the arrangement. Take a look at Apples documentation on supporting multiple Interface Orientations.

I hope this helps :)

Ryan
  • 160
  • 12
  • +1, thanks. the problem is - it is for iOS 5-7. So simply using autolayout will not help I think. – Nirav Bhatt Dec 02 '13 at 03:47
  • Thanks Nirav. There are some interesting solutions to that problem in another SO: http://stackoverflow.com/questions/12411980/enabling-auto-layout-in-ios-6-while-remaining-backwards-compatible-with-ios-5 – Ryan Dec 02 '13 at 19:21