views:

113

answers:

3

i am trying to pull a map in my applcation with interface builder using MKMapView but for some reason its not showing up. Also i want to add some button to this view by clicking which i can browse a file existing in my iphone.

Please provide me with the detial description as i am new to this.

Thanks,

A: 

You'll want to add an annotation to the map, then provide a custom view for it.

To add an annotation to the map, adopt the MKAnnotation protocol in one of your objects and set its coordinate property to the appropriate lat/lon location.

Next, you'll add the annotation to the map using MKMapView addAnnotation.

Set the map's delegate property to your view controller, then implement mapView:viewForAnnotation:

When this method gets called, return a MKAnnotationView for your annotation. Set the MKAnnotationView's image property to whatever image you want the annotation to use (an image of a button perhaps?).

You can implement mapView:didSelectAnnotationView: if you want to know when the annotation was selected.

You can also set a callout accessory button on the annotation using MKAnnotationView's leftCalloutAccessoryView and rightCalloutAccessoryView properties. If you do this, you can then respond when the user selects the callout button by implementing mapView:annotationView:calloutAccessoryControlTapped:.

Avalanchis
Actually what i am trying to do is, to pull a map in my applcation with interface builder using MKMapView but for some reason its not showing up. Also i want to add some button to this view by clicking which i can browse a file existing in my iphone.
Ashutosh
A: 

Actually what i am trying to do is, to pull a map in my applcation with interface builder using MKMapView but for some reason its not showing up. Also i want to add some button to this view by clicking which i can browse a file existing in my iphone

Ashutosh
You should edit your original question to clarify what you are trying to do instead of adding an answer.
Avalanchis
A: 
  • (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id )annotation { static NSString *AnnotationViewID = @"annotationViewID";

    annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];

    if (annotationView == nil) { annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease]; } annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; annotationView.image = [UIImage imageNamed:@"s11.png"];

    annotationView.annotation = annotation;

    [annotationView setEnabled:YES]; [annotationView setCanShowCallout:YES];

    return annotationView; }

RakeshBhatt
using this you can add button in the annotation of your pi,
RakeshBhatt
Thanks for sharing this info but how can we simply pull a map through interface builder by drag n drop. I did the same thing but it didn't show up.Thanks
Ashutosh