According to Apple one should have 2 controllers and 2 nibs in order to support landscape and portrait orientations.
The problem is this sample is very simple. In my project I have a far more complex situation and its an iPad app so its far more work.
The problem that I have is:
A – duplication of code
(both
controllers have the same code because
the UI is that similar)
Blockquote
B – processing
needs to be repeated e.g. in portrait
the app loads, data is retrieved and
processed e.g. images are created etc
then the user switches to landscape,
this data needs to be retrieved again
or at least processed again.
How do I share the code and the data between the 2 controllers?
Two controllers and nibs is not a requirement or even necessary. By properly setting the autoresizing mask for your views, you can frequently avoid any additional code.
If the autoresizing behavior isn’t sufficient, the easiest way to create two view controllers is to create one parent
UIViewControllerand two children view controllers.