Custom call

I am using SMCalloutView to create a custom callout for my mapView. The problem I am running into is when the leader view is visible and the user clicks on the leader, if another annotation is under the leader view, it will reject the currently selected annotation and select the one below the leader visible.

I thought that maybe I could subclass UIView to catch all touch events. So I created a subclass of UIView, all functions work correctly if I add it directly to the mapView. But when I use it for a popover it doesn't work at all.

 import Foundation
 import UIKit

class popOverSub: UIView {

override init(frame: CGRect) {
    super.init(frame: frame)

    let myTap = UITapGestureRecognizer(target: self, action: "touchEventTest")
    addGestureRecognizer(myTap)
    userInteractionEnabled = true
    backgroundColor = UIColor.greenColor()

}

required init(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

func touchEventTest() {

    println("touchEventTest")
}

override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
    println("touch begins")
}
}

      

To complete here, I am calling a custom CalloutView.

func mapView(mapView: MKMapView!, didSelectAnnotationView view: MKAnnotationView!) {

 let popView = popOverSub(frame: CGRect(x: 0, y: 0, width: 100, height: 200))
            calloutView.contentView = popView
            self.calloutView.calloutOffset = CGPoint(x: view.frame.width*0.5, y: 0)
            self.calloutView.delegate = self

            calloutView.presentCalloutFromRect(calloutView.bounds, inLayer: view.layer, constrainedToLayer: self.mapView.layer, animated: true)
}

      

What do I need to do. If the user clicks on the callout view, it does not reject the callout, or sends a touch event to the mapView / Annotation at the bottom. Instead, you need to call the function. Any advice would be great.

+3
swift mkmapview uitouch


source to share


No one has answered this question yet

Check out similar questions:

13
Setting up iOS8 Callout bubble (Swift)
eleven
How to override UIView initializer in Swift 1.0
five
Click MKAnnotationView to deselect and hide its leader
4
Adding a custom UIViewcontroller for a routine programmatically, but getting the error "Unable to convert value to type ..."
2
MapBox - Detect ZoomLevel Changes
2
Stop MapView coverage from spreading strokes
1
draw (_ rect: CGRect) is not getting called in custom view
1
Problems with casting cell types to remove
1
Create custom table table cell with swift
0
Customized iOS MapKit callout on the pin side



All Articles
Loading...
X
Show
Funny
Dev
Pics