开发者

Updating an AnnotationView Callout after details entered in View Controller that was pushed form the map view

I have a simple maps app with multiple pins on a map view. My intention is to tap a pin, show a callout with an accessory view, push to a Detail View Controller where you can edit that pin/locations details. This all works fine, but once i pop the Detail View Controller the callout on the map view is still there, which i want, but it still has the old uneditied values. How can开发者_运维百科 i refresh/update the callout view once the Detail View Controller is popped?

I am using Core Data with a simple database. I have tried using controllerdidchangecontent, Map View Controller Will Display methods etc but my main problem is identifying which object has been added/updated/deleted and which is the corresponding callout/selected pin.

Any help appreciated...


Not sure if you had find your answer but the way to do it is to extend MKAnnotation class and creating custom annotation and passing them while creating placemarks. Later you can get them from MKAnnotationView's annotation property.

See a good implementation here

http://www.slideshare.net/360conferences/getting-oriented-with-mapkit-everything-you-need-to-get-started-with-the-new-mapping-framework


The only way I could find to update the callout info was to mess directly with the subviews of the callout.

The callout view is the first subview of the annotation view.

In the following example, I update the subtitle.The title label is the 6th and the subtitle is the 7th subview of the callout:

if (myAnnotationView.subviews.count > 0)
    ((UILabel*)[((UIView*)[myAnnotationView.subviews objectAtIndex:0]).subviews objectAtIndex:7]).text = @"Some example";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜