开发者

Design issues supporting both orientations using apple guidelines

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 开发者_StackOverflow社区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 UIViewController and two children view controllers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜