MapKit: how to create a custom annotation view using a button in a .xib file?

I am using Xcode 5 and the latest iOS SDK, and it is very difficult for me to understand how to create custom annotations using a click button.

All I need is a user annotation with a button that appears when the user clicks on my MKMapView. After some tutorials, I managed to create a custom class that loads the .xib file, and that already works. However, the problem is that whenever I try to click a button placed as an annotation, the contact is not selected. I would like to be able to design my annotation in a .xib file rather than create it 100% programmatically. Is there any way to do this?

Thank,

Niklas

+3
source share
1 answer

There is a great map tutorial on the site that I used when I first started working in this iOS section. It can be found here: http://www.raywenderlich.com/21365/introduction-to-mapkit-in-ios-6-tutorial (Just FYI, this is a great resource to learn more about iOS.)

In any case, this paragraph should sound familiar (regarding what you need):

Now you have done this so that in the leader, when the contact is pressed, a button will appear on the right side. When this is used, the mapView: annotationView: calloutAccessoryControlTapped: method is called. In this method, you grab the MyLocation object to which this short belongs, and then launch the Maps application by calling the openInMapsWithLaunchOptions: method.

, "", , .

, , :

http://www.raywenderlich.com - , . . / PDF-, .

http://www.cocoacontrols.com - , , . , iOS.

http://www.nshipster.com -

http://objc.io - .

+3

All Articles