Handle Onclick(on tap) event for iPhone Map Annotations - iphone

I have plotted annotations in iPhone Map, now I need to handle the onclick/ontab event for the annotation. Please provide the ways to do that.
Thanks,
Chandra

When annotation gets selected map view calls mapView:didSelectAnnotationView: method in its delegate, so to handle tap event you should implement that method in your map delegate.

First you should give title to pins.If you give then only the delegate methodmapView:didSelectAnnotationView:. tou can handle now.

Related

Programmatically display a GMSMarker's info window

I know there is already a question similar to this on SO (Displaying info window when tapped marker in google maps iOS sdk while implementing mapView:didTapMarker: delegate method implemented) but the answer does not apply in my case.
In my mapView(didTap:) delegate method, it has to return true because I programmatically determine the camera position when a marker is tapped. If I return true like the answer in the above question says, the map is automatically centered on the selected marker, which I do not want. Since I return true, tapping a marker does not display the marker's information window, which I still want to occur, so is there a way for me to do that programmatically?
I don't think the code in my mapView(didTap:) delegate method is necessary for answering this question, but if anyone needs it, let me know. (Keep in mind that my question question refers to the delegate method for when a marker is tapped, not the delegate method for when an info window is tapped, mapView(didTapInfoWindowOf:))
Thanks in advance.
Edit:
Looking through the Google Maps Documentation, I found out that there is a method for what I am looking for in JavaScript called showInfoWindow() that you call on the marker who's info window you want to show (this is the link to the documentation I'm talking about). So does anyone know a Swift 3 alternative to this method?
Edit:
If I return false in the delegate method, the camera instantly moves to the marker's location for a split second, and then pans over to the location I programmatically tell it to move to. This technically works, but it is ugly and not fluent, so I still need a way to programmatically show the marker's information window while the delegate method returns true.
After going on google's issue tracker and submitting a post, I found out that mapView.selectedMarker() = marker does not actually have any connection to the mapView(didTap:) delegate method, so returning true in the delegate method has no impact on the selectedMarker() method's functionality.
As a result I can just add mapView.selectedMarker() = marker in the delegate method after customizing the location I want to animate the mapView to and before returning true, which causes the marker's info window to pop up without messing with the camera position.

Send data from chosen Annotation (InfoBoule button)

I have a mapView which loads annotations with the help of a web service. I parse the data in json in an array and get the values of each annotation.
But now, I want to send the information of the annotation in selection.
As I can think, It mar rather be like the section in UITableView called DidSelectRow...
How I can do this?
If you mean when the user taps one of the annotations in mapView, you have a delegate method for that. From MKMapViewDelegate Protocol Reference
mapView:didSelectAnnotationView:
Set your view controller as delegate for your mapView and then just use this delegate method to be notified when the user taps on one of your annotations.
Link to Apple Documentation on MKMapViewDelegate Protocol

How to tell when MKMapView and visible MKAnnotationView are finished drawing?

I'm displaying a MKMapView with MKAnnotations some of which are selected and showing their Annotation.
I am trying to grab an image of the displayed map and annotations using the -renderInContext.
90% of the time the Map, MKPinAnnotationView's and selected annotations are correctly captured.
The other 10% of the time the image is missing something, usually the MKPinAnnotationViews or their annotations if selected.
I've added code to deal with the Map itself loading it's map data.
But I haven't been able to track down something that would indicate to me that all of the visible MKPinAnnotationView's have been drawn
and if selected their annotations displayed??
the closest hint I've come across is the addObserver, although I haven't figured out what could be observed that would tell me when all of the drawing is done.
Thoughts?
ok I'm an idiot...
I finally tracked down the problem. In my viewForAnnotation routine in the MKMapView Delegate protocol I wasn't correctly setting values for reused MKPinAnnotationView's.
So some of the time I would reuse a view that had .canShowCallout set to YES and other times I'd reuse a view that had .canShowCallout set to NO.
.<
Try using the MKMapViewDelegate didAddAnnotationViews method.
If in that method, the drawing is still not ready for your requirements, you could then in there call your capturing method with performSelector:withObject:afterDelay:.

How to handle an Event of a programmatically created object?

That's a very basic question.
How can I catch for example the "touchesBegan" event of a UIWindow instance? So that whenever the user is touching the window a method I set is called?
Thank you!
F.
For iOS 3.2+: Create a gesture recognizer and add it to the view you are interested in.
Posting the tutorial that got my head around Gesture Recognisers:
http://www.conceitedcode.com/2010/06/implementing-gesture-recognizers/
F.

How to call a method when the Done Button in the KeyBoard is Clicked?

I want to call a method when the done button is clicked in the UITextField KeyBoard? Please Help me...
It's not even necessary to implement the delegate. I greatly prefer using good, old-fashioned target/action pattern to handle this. It can also lead to cleaner code if you have multiple ways of ending editing (say, intercepting touches outside the text field to cancel editing).
To use target/action, simply wire up UIControlEventEditingDidEndOnExit, which shows up in Interface Builder as the Did End On Exit event.
No muss, no fuss. A lot cleaner and easier than implementing the delegate.
See the UITextFieldDelegate Protocol reference. You probably want to implement the – textFieldShouldReturn: method in your delegate.