ios - Is it ok to keep multiple child view controllers associated with a parent UIViewController even when their views are not visible? -


scenario: have set of objects. wish display them using uitableview when device in portrait mode, , in uicollectionview when in landscape. accomplish this, want use uiviewcontroller container, , give 2 child view controllers (one each uicollectionviewcontroller , uitableviewcontroller). expect orientation change often, resulting in parent swapping , forth between 2 child controllers.

in view controller programming guide ios (2012-12-13), on pages 117 , 118 talking transitions between children, remove child view controller parent whenever child's view removed view hierarchy. (see listing 14-3 in particular.)

is necessary memory or whatever other reasons, or ok keep both child view controllers associated parent, , flip , forth between views? there performance advantages either technique?

there no problem having both view controllers children, need ensure appropriate resources either shared between them (i.e. don't have 2 copies of objects display) or released when views shown , hidden.

in case, 2 view controllers displaying same data, assume when switch between 2 update scrolled position based on happened in other view. if case there isn't lot of benefit keeping other view controller allocated , child. thing save allocated cells cached inside view. memory efficient should remove view controller isn't on display. costs little more @ runtime should not noticeable.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -