我有自定义注释。我不时给它制作动画:
UIView.animateWithDuration(duration, delay: 0, options: .CurveLinear, animations: {
customAnnotation.coordinate = newCoordinate
虽然发生这种情况但我无法点击它来调用mapView:didSelectAnnotationView
我甚至将UIButton添加为子视图:
let button = UIButton(frame: CGRect(x: 7.25, y: 17, width: 37, height: 15))
let text = customAnnotation.displayedName
button.setTitle(text, forState: .Normal)
button.backgroundColor = UIColor.blackColor()
button.setTitleColor(UIColor.greenColor(), forState: .Normal)
button.addTarget(self, action: "buttonTapped:", forControlEvents: .TouchUpInside)
customAnnotationView?.addSubview(button)
mapView中的:viewForAnnotation但它也不起作用。 有什么想法吗?
答案 0 :(得分:1)
以下使用可能适合您。
View.animateWithDuration(duration, delay: 0, options: .CurveLinear | .AllowUserInteraction , animations: {
customAnnotation.coordinate = newCoordinate
})
答案 1 :(得分:0)
您可以在UIViewAnimationOptions
中传递的其他options
参数之一是.AllowUserInteraction
public static var AllowUserInteraction: UIViewAnimationOptions { get } // turn on user interaction while animating
要将多个参数传递给options
,请将它们传递给数组,如下所示:
UIView.animateWithDuration(duration, delay: 0, options: [.CurveLinear, .AllowUserInteraction], animations: {
customAnnotation.coordinate = newCoordinate
希望对你有所帮助。