ios - 动画时无法点击注释

标签 ios objective-c swift mapkit

我有我的自定义注释。我时不时地为它制​​作动画:

 UIView.animateWithDuration(duration, delay: 0, options: .CurveLinear, animations: {
                        customAnnotation.coordinate = newCoordinate

当发生这种情况时,我无法点击它来调用 mapView:didSelectAnnotationView

我什至将 UIButton 添加为 subview :

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 中,但它也不起作用。 有什么想法吗?

最佳答案

使用下面的方法可能适合您。

 View.animateWithDuration(duration, delay: 0, options: .CurveLinear | .AllowUserInteraction , animations: {
                            customAnnotation.coordinate = newCoordinate
})

关于ios - 动画时无法点击注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39291423/

相关文章:

基于错误的枚举关联值,使用多个 catch 和条件进行快速错误处理

ios - Swift 4 CLLocation 用户位置经度和纬度

ios - 将事件保存到用户的日历

android - 图书馆可以注册应用程序以获得通知吗?

ios - 检查 super View 是否是 UITableViewController UIViewController?

swift - 获取父类(super class)的克隆

ios - 如何使用 RxDatasource 在具有多个 header 的 UICollectionView 中创建多个部分

ios - TextView文本点击键盘上的删除按钮后不删除文本

objective-c - 应用验证失败 : Unable to create Configuration directory:/user/username/. itmstransporter

ios - 设置 rowHeight 等于 UITableViewAutomaticDimension 不起作用