iphone - Need help opening callout of annotation on map automatically, when map first loads -


dear fellow iphone/objective-c developers:

i have navigation based application iphone working allows user view selection table, on map. have annotation pinpoints user's selected location on map. per normal behaviour, if user clicks on annotation, callout appears details location. no problems here. question is, i'd callout appear automatically annotation, once user taken screen containing map, user not have click on annotation in order see details location, i'm not sure how this. have following method in "mapviewcontroller" class, bulk of map display work performed:

- (void)viewdidload {     [super viewdidload]; mkcoordinateregion region; mkcoordinatespan span;  navbuttonappdelegate *delegate = [[uiapplication sharedapplication] delegate]; usercoord = delegate.userlocation.coordinate;  region.center = usercoord;  span.latitudedelta = 0.4; span.longitudedelta = 0.4; region.span = span;  [mapview setmaptype:mkmaptypestandard]; [mapview setzoomenabled:yes]; [mapview setscrollenabled:yes]; mapview.showsuserlocation = yes; [mapview setregion:region animated:yes];   restaurantannotation *rannotation = [[restaurantannotation alloc] init]; rannotation.title = restaurantobj.name;   rannotation.subtitle = restaurantobj.address; rannotation.subtitle = [restaurantobj.address stringbyappendingformat:@" %@", restaurantobj.hours];  rannotation.subtitle = [restaurantobj.address stringbyappendingformat:@" %@", restaurantobj.phonenumber];    cllocationcoordinate2d newcoord = {restaurantobj.latitude, restaurantobj.longitude}; rannotation.coordinate = newcoord; [mapview addannotation:rannotation]; 

}

the mapviewcontroller called following method in previous screen:

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {  restaurant *rlocation = [restaurantlist objectatindex:indexpath.row];  mapviewcontroller *mapcontroller = [[mapviewcontroller alloc] initwithrestaurant:rlocation]; [self.navigationcontroller pushviewcontroller:mapcontroller animated:yes]; [mapcontroller release]; 

}

i realize, have use following method accomplish this:

- (void)mapview:(mkmapview *)mapview didaddannotationviews:(nsarray *)views {     id<mkannotation> myannotation = [mapview.annotations objectatindex:0];     [mapview selectannotation:myannotation animated:yes]; } 

however, i'm not sure how. don't have many annotations using @ once, have 1 annotation need work with.

where put method in app, , call from?
call method viewdidload method , put actual method inside mapviewcontroller class?

thanks in advance reply.

you have add

- (void)mapview:(mkmapview *)mapview didaddannotationviews:(nsarray *)views {      id myannotation = [mapview.annotations objectatindex:0];      [mapview selectannotation:myannotation animated:yes];  } 

to class set delegate mkmapview.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -