iphone - how to access parents of view controller and properly dismiss self and self.parent? -
in myviewcontroller
, ask user select person address book: (on button click)
peoplepicker = [[abpeoplepickernavigationcontroller alloc] init]; peoplepicker.peoplepickerdelegate = self; [self presentviewcontroller:peoplepicker animated:yes completion:null];
if user selects person more 1 phone number, present new uitableviewcontroller allows user select 1 of phone numbers:
- (bool)peoplepickernavigationcontroller:(abpeoplepickernavigationcontroller *)peoplepicker shouldcontinueafterselectingperson:(abrecordref)person { // ... next = [[choosepersonphoneviewcontroller alloc] initwithstyle:uitableviewstylegrouped personphoneinfoarray:personphoneinfos]; [peoplepicker pushviewcontroller:next animated:yes]; // ... }
when user selects phone number, bring phone number original viewcontroller , close both abpeoplepickernavigationcontroller
, choosepersonphoneviewcontroller
.
two questions:
- how close both view controllers within
choosepersonphoneviewcontroller
? - how access
myviewcontroller
withinchoosepersonphoneviewcontroller
?
my guess that:
abpeoplepickernavigationcontroller *peoplepicker = (abpeoplepickernavigationcontroller *)self.navigationcontroller; myviewcontroller *nsvc = (myviewcontroller *)peoplepicker.presentingviewcontroller;
i have tried many combinations using parentviewcontroller
, presentingviewcontroller
, popviewcontroller
/ dismissviewcontroller
, can't figure out - keep getting exceptions show lack of understanding of view controller hierarchy. appreciate pointers or @ least rtfm links.
once have second question answered, first question becomes easy. in choosepersonphoneviewcontroller, have property of same class myviewcontroller named parent, , when allocate choosepersonphoneviewcontroller myviewcontroller, set self, set delegate self. once parent set, can call methods in parent child object.
Comments
Post a Comment