我正在为mapview实现自定义标注视图.我得到了这个输出
对于我正在使用的注释视图
func mapView(mapView: MKMapView!,viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! { let reuseId = "mapPin" var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? CustomCalloutView if anView == nil { anView=CustomCalloutView(annotation: annotation,reuseIdentifier:reuseId) anView!.image = UIImage(named:"mappin.png") let button : UIButton = UIButton.buttonWithType(UIButtonType.Detaildisclosure) as! UIButton button.addTarget(self,action: "buttonClicked:",forControlEvents: UIControlEvents.TouchUpInside) anView!.rightCalloutAccessoryView=button //anView!.addSubview(viewC) mapViewControl.addAnnotation(annotation) } else { anView!.annotation = annotation } return anView }
并弹出标注视图
func mapView(mapView: MKMapView!,didSelectAnnotationView view: MKAnnotationView!){ var viewC:UIView=UIView(frame: CGRectMake(0,50,50)) viewC.backgroundColor = UIColor.blackColor() view.addSubview(viewC) viewC.center = CGPointMake(viewC.bounds.size.width*0.1,-viewC.bounds.size.height*0.5) }
解决方法
我得到了解决方案它的变化非常小.在viewForAnnotation中隐藏基本标注如下,
anView!.canShowCallout = false
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。