Custom MKAnnotation with drag & drop animation - iphone

I have an annotation with custom image and drag'n'drop support. But I need to animate the annotation the same way default Google pin is animated. That means the annotation should "jump up" when I drag it and "fall down" when I release it.
I was quite surprised that this animation isn't working anymore when I change annotation's image.
Thanks.

I have found the answer here: Subclassing MKAnnotationView and overriding setDragState. I used bad keywords when I was trying to find the answer before.

Related

Unable to tap UIImage subview over MapKit view - Swift 4

I've been having trouble interacting with an image that I've constrained to the upper left portion of my view. Everytime I try to tap on said images, my #selector method fails to invoke. I've had no difficulties tap-interacting in other view controllers where I don't have my map. Is it inherently impossible to tap UIImage objects over a MapKit map? I've done everything from creating delegates to checking for pesky nuances like setting my image object's isUserInteractionEnabled to true.
So we've decided to place a button of the same size with the same placement as the image, but we set the color property of the button to isOpaque = true. This is functional, but very hacky. I'd still like to know if anyone has been able to crack this predicament of mine without resorting to such a roundabout way. If anyone has an answer, I'm all for self-improvement, so please don't hesitate to contribute to this thread! Thanks guys!

Remove the Standard callout from MapView

I need to remove the Standard Callout from the mapview and want to display my custom callout. My custom Callout is having image and many fields. I am designing my custom callout in interface builder.
How I can display my custom callout ?
I have referred to the link "Custom callout Bubble", But I want to display the custom callout from xib.
It's not simple, but you can do it.
You need to create an alternative MKAnnotationView (BubbleView) and show it when you select the first one.
It's possible to differentiate the AnnotationView from BubbleView in delegate.
You have a lot of work to do, this tutorial can help you to understand the passages, but pay attention on iOS 6, some things are changed and there are some problems in BubbleView positioning
http://www.jakeri.net/2009/12/custom-callout-bubble-in-mkmapview-final-solution/
Custom callouts are nearly impossible to implement. You have to simulate a callout by adding your own custom MKAnnotationView to your MKAnnotations, listen to their selection, then listen to your MKANnotationView's didMoveToSuperView callbacks to handle your own animations and drawing.
My implementation on the iPad took weeks to get right and if I were to do it again I wouldn't use Apple's MapKit at all. I'd use another mapping framework altogether that made the process easier.
tldr - you can't do it - trust me

Dragging a custom pin on a Map View

I've managed to create a custom image for the pin which is dropped on a map, using MKAnnotationView...
My question is how do I make this custom image draggable on the map? So I can move the image to other parts of the map?
Have a look at the MKAnnotationView docs. There's a property called draggable there, and you have to also implement the MKAnnotation protocol setCoordinate: method to update the position of the annotation.
Don't forget that it's only supported in iOS 4.0 and above.
You can look this tutorial : mapkit-annotation-drag-and-drop-with

Focus and zoom in on a UITextField when touched?

How in the world does one get the iPhone view to zoom in on a focused UITextField? I need to tap on a text field that I want to edit, and my view should zoom in to the tapped text field and pull up the keyboard (which it already does), similar to how many Internet text fields gain focus on the iPhone. Is this some type of overlay?
I've been looking everywhere for this solution but maybe I've just got the wrong terminology. Thank you in advance.
Could be a duplicate of this StackOverflow question.
In essence, there are a number of ways, but you have to program this effect manually. A textfield is already an overlay. You can either move it, or scroll the containing view.
Please follow the following steps.
Implement the delegate method for all textfield.connect the outlet of textfield in interface builder basically it's setting the delegate property.then in delegate property you can defined the method whatever you want to implement or wanted to do functionality.
Thanks

MKAnnotationView in both hovering and pinned states

I'm trying to add a pin (MKAnnotation and MKAnnotationView) to my MKMapView and allow the user to drag it around.
I'd also like to make the dragging of the pin animated and interactive like the iPhone's Map App.
My question is how do I change the state of the MKAnnoationView so that it's hovering over the map (so the pin isn't actually inside the map)?
I'm not 100% sure how to do this.
At present, my colleague as found an hovering image that he swaps with the default MKAnnotationView, but that means I can't easily animate between the two.
Not sure what you exactly want to do but I have used Apple's example in the iPhone App Programming Guide (Handling Events in an Annotation View) to implement the draggable pin.
It has a partial code but tha may be enough for you to figure it out.
Basically, you must subclass the MKAnnnotation and MKPinAnnotationView and in your CustomAnnotationView class you have to implement delegate methods to handle touch events, as shown in the Apple example.
There was a bit of filling out or modification needed because the code snippet was not complete, but I have reproduced the behaviour of the pin on the Apple's iPhone Map app exactly (except that I did not implement the right accessory button).
In it, the pin feels like it is hovering. So, I suspect that you have no need for the hovering image you have mentioned.
I also presume that by providing a BOOL property, you could make the pin draggable or "fixed" programmatically.
Does this help?