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.
source to share
No one has answered this question yet
Check out similar questions: