I know this question has been asked before, but how can I support a different view depending on my interface orientation in iOS 5?
An example by Apple shows a PortraitViewController and a LandscapeViewController. The PortraitViewController creates the LandscapeViewController and registers itself for rotation notifications. When it receives a rotation notification it either pushes or pops the LandscapeViewController depending on current interface orientation.
So far so good.
But how can I keep data both controllers have synchronized? (They display the same data obviously, since they are technically the same controller to the user, just with different views in landscape and portrait). Both have a “reload data button” which reloads their data. How can I tell the PortraitViewController to show the same data when the LandscapeViewController reloads it and vice versa?
Another problem is with memory warnings. When the interface is in landscape mode and I receive a memory warning my PortraitViewController gets unloaded. Now if I reload the data for my LandscapeViewController the PortraitViewController cannot do the same, because it is unloaded and has its Outlets still set to nil.
How do I adress all of these issues?
So what I ended up doing is using one ViewController with 2 views which shows a different view depending on interface orientation. The downside of this is that I have to connect all outlets twice and manipulate them twice.
But this way I can easily share my data and avoid one view being unloaded while the other isn’t.