ios - Keeping a reference to the Parent in View Controller Containment -
ios - Keeping a reference to the Parent in View Controller Containment -
consider basic uiviewcontroller, contained in uinavigationcontroller or uitabbarcontroller. view controller has reference container, either:
self.navigationcontroller self.tabbarcontroller
now consider basic illustration of view controller containment without navigation controller or tab bar controller:
[self addchildviewcontroller: child]; [[child view] setframe: [[self view] bounds]]; [[self view] addsubview: [child view]]; [child didmovetoparentviewcontroller: self];
if want kid view controller have reference container, what's best method doing that?
my guess in child:
@property (weak, nonatomic) mycontainercontroller *container;
and set @ same time i'm adding kid parent, so:
[child setcontainer: self];
is correct?
i want ensure can reference container child, i'm concerned memory issues. believe strong property prevent arc releasing child, if remove container. assumption correct?
you have reference self.parentviewcontroller. there's no need create own. have @ "getting other related view controllers" section of uiviewcontroller class reference.
ios objective-c uiviewcontroller uikit
Comments
Post a Comment