首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从MKAnnotationView访问mapView.annotations

从MKAnnotationView访问mapView.annotations
EN

Stack Overflow用户
提问于 2015-08-04 06:59:05
回答 1查看 726关注 0票数 1

试图动画我的定制别针形象。

但是,我无法找到访问MKAnnotationView的方法。

例如,当您使用

代码语言:javascript
运行
复制
func mapView(mapView: MKMapView!, didSelectAnnotationView view: MKAnnotationView!) {

}

就像你在那里看到的一样。

但我想要能够动画的一套别针,我已经放大到的领域。

使用注解的内置mapView属性,我可以获得所需的引脚。

所以在

代码语言:javascript
运行
复制
    func findThePins(searchName:String) {

    var foundItems = [Client]()

    for aPin in mapView.annotations as! [Client] {

        if aPin.clientName.uppercaseString.rangeOfString(searchName.uppercaseString) != nil {
            foundItems.append(aPin)
        }
    }

    if !foundItems.isEmpty {
        println("move map - \(foundItems.count)")
        // moves to show the area of the screen containing the pins
        mapView.showAnnotations(foundItems, animated: true)
        // How to animate those pins in foundItems
    }
}

我如何访问视图,以便我可以动画。我有种感觉,我走错路了。

didSelectAnnotationView中运行良好的示例动画

代码语言:javascript
运行
复制
UIView.animateWithDuration(1.0, delay: 0.0, options: nil, animations: { () -> Void in
pinView.transform = CGAffineTransformMakeScale(2.0, 2.0)
}, completion: { (completed) -> Void in
pinView.transform = CGAffineTransformIdentity
})

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-02 04:00:27

问题解决了!

代码语言:javascript
运行
复制
let clientAnnotation = self.mapView.viewForAnnotation(client)
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31802663

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档