开发者

Trying to play with the annotation and bubble callout on mkmapview

开发者 https://www.devze.com 2023-03-09 20:12 出处:网络
I am developing an application in iphone which deals with maps. I have many annotations. I need different images to be loaded in the callout bubble.It mean user can edit the callout it may be image an

I am developing an application in iphone which deals with maps. I have many annotations. I need different images to be loaded in the callout bubble.It mean user can edit the callout it may be image and He also type text on callout bubble .How can I give give multiple action on the callout bubble .

And most important think is that this annotation must drop on the map after clicking the save button. For Example I have two class (mapview And photoview),And in photoView i have three button (chooshphoto,takephoto,useph开发者_开发技巧oto)when user take photo or browse for photo and he want use this photo.When he click on usephoto button the annotation must drop after that.And display onthe mapView.


The second half of your question isn't very clear but I'll try and answer the first.

The only real customisation you can apply to the callout view for an MKAnnotation is to set the Title, subtitle labels and the left/right calloutAccessoryViews. You can set the latter to images or callOutAccessoryViewIndicators, or another UIView but it can't be taller than 32 pixels. MKAnnontationView documentation

That's really about it I'm afraid. For anything more advanced than that, you'll have to create a custom implementation. This blog post should be helpful, I plan on building something similar myself.

MKPinAnnontationView can be set to drop on the map as you describe so as long as you're happy with the Pin image for the annontation view itself, you can simply set it's animatesDrop property to YES and it will animate onto the map when it's added.

MKPinAnnontationView documentation

EDIT: I think this is what you want;-

In your mapView controller, define a property to hold the object you want to animate.

@interface MyMapViewController {

    Photo *photoToAnimate;

}
@property (nonatomic, retain) Photo *photoToAnimate;

@end

Then in your implementation file, add the following to ViewDidAppear

-(void)ViewDidAppear {
     ...
     if (photoToAnimate) {
         [mapView addAnnotation:photoToAnimate];
         self.photoToAnimate = nil; // reset it for the next time
     }
     ...
 }

Then in your PhotoViewController, simply set the property on the button press

-(void)usePhotoAction {
    ...
    mapViewController.photoToAnimate = photo;
    ...
 }

At least that's the really simple hacky way of what I was trying to describe in the comments. ViewDidAppear will fire when the MapView re-appears and it will add the pin to itself accordingly. If you need to add more than one pin, use an array to store them and iterate through the array.

There might be better patterns for this but in short, your MapView needs to get hold of the object you want to drop somehow and then not actually do anything with it until ViewDidAppear is called.

0

精彩评论

暂无评论...
验证码 换一张
取 消