Multiple Views within one XIB - iPhone SDK

前端 未结 3 1882
-上瘾入骨i
-上瘾入骨i 2021-01-31 11:25

I have been spending time learning how to use the iPhone SDK. I\'ve read \"Beginning iPhone Development: Exploring the iPhone SDK\" from cover to cover and I\'ve never seen an e

3条回答
  •  一向
    一向 (楼主)
    2021-01-31 11:51

    It's a question of memory optimization and loading times. If you put all your views in one XIB, then when your application launches, it has to load the entire XIB into memory and construct all of the objects for all of the controls, and this takes a non-trivial amount of time.

    If instead you separate your views into separate XIBs, then your app will start up much faster, because only the XIB containing the initial view will be loaded, and it will also use less memory at first. Then, when the view changes, you can load the XIB containing the new view lazily. This will incur a minor hitch when opening a view for the first time. If you're really trying to optimize memory use, you can also unload the previous view when switching views, but I wouldn't recommend this, as this will incur a hitch every time you switch views, instead of just the first time you switch to any given view.

提交回复
热议问题