ios - Setting delegate to MKMapView -


i new ios programming. have created viewcontroller mkmapview element, , wanted set delegate [mapview setdelegate:self]

first done in method initwithnibname:bundle: like:

- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];     if (self) {           [[self map] setdelegate:self]];         uitabbaritem *item = [[uitabbaritem alloc] init];         [item settitle:@"map"];         [self settabbaritem:item];     }     return self; } 

in case mkmapview did not send me messages, when placed setting delegate message viewdidload method, worked fine.

could explain me why not working when setting delegate message in initwithnibname:bundle?

views not loaded in initwithnibname, initializes viewcontroller class , load xib file contains view details.

when viewcontroller calls viewdidload, have view objects allocated , initialized.

in case, when setdelegate in initwithnibname, calling on nil value, nothing set, in viewdidload mapview allocated , initialized, works fine.

for deeper insight refer:

http://developer.apple.com/library/ios/#featuredarticles/viewcontrollerpgforiphoneos/viewloadingandunloading/viewloadingandunloading.html

beautiful explanation here: what process of uiviewcontroller birth (which method follows which)?

looking understand ios uiviewcontroller lifecycle

http://thejoeconwayblog.wordpress.com/2012/10/04/view-controller-lifecycle-in-ios-6/

view life-cycle


Comments