ios – 如何更改注释标注窗口Swift的高度

ios – 如何更改注释标注窗口Swift的高度,第1张

概述如何在 Swift中更改Map上的注释标注窗口的大小.我尝试在右视图和左视图的每个组件上创建一个更大的CGSize但没有任何成功最终视图的高度仍然是相同的. 这是我的代码: func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { print("d 如何在 Swift中更改Map上的注释标注窗口的大小.我尝试在右视图和左视图的每个组件上创建一个更大的CGSize但没有任何成功最终视图的高度仍然是相同的.

这是我的代码:

func mapVIEw(mapVIEw: MKMapVIEw,vIEwForAnnotation annotation: MKAnnotation) -> MKAnnotationVIEw? {    print("delegate called")    if !(annotation is CustomPointAnnotation) {        return nil    }    let reuseID = "test"    var anVIEw = mapVIEw.dequeueReusableAnnotationVIEwWithIDentifIEr(reuseID)    if anVIEw == nil {        anVIEw = MKAnnotationVIEw(annotation: annotation,reuseIDentifIEr: reuseID)         selectedUstanova = (annotation as! CustomPointAnnotation).ustanova        anVIEw!.canShowCallout = true    }    else {        anVIEw!.annotation = annotation    }    //Set annotation-specific propertIEs **AFTER**    //the vIEw is dequeued or created...    let cpa = annotation as! CustomPointAnnotation    anVIEw!.image = UIImage(named:cpa.imagename)    return anVIEw}func mapVIEw(mapVIEw: MKMapVIEw,dIDSelectAnnotationVIEw vIEw: MKAnnotationVIEw){    let button : UIbutton = UIbutton(type: UIbuttonType.Custom) as UIbutton    let image = UIImage(named: "telephone")    button.layer.cornerRadius = 10    button.layer.backgroundcolor = UIcolor.whitecolor().CGcolor    button.layer.masksToBounds = true    button.setBackgroundImage(image,forState: UIControlState.normal)    button.frame = CGRectMake(0,35,200)    button.addTarget(self,action: "buttonClicked:",forControlEvents: UIControlEvents.touchUpInsIDe)    let labelTitle :   UILabel = UILabel(frame: CGRectMake(20,150,50))    labelTitle.text = selectedUstanova!.ime    let labelSubTitle :   UILabel = UILabel(frame: CGRectMake(20,50,100))    var ustanovaOpis = ""    if selectedUstanova!.opis != nil{        ustanovaOpis+=selectedUstanova!.opis!+"\n"    }    if selectedUstanova!.telefon != nil{        ustanovaOpis+=selectedUstanova!.telefon!    }    labelSubTitle.text = ustanovaOpis    let leftCAV : UIVIEw = UIVIEw(frame: CGRectMake(0,250,250));    let leftCAV2: UIVIEw = UIVIEw(frame: CGRectMake(0,250));    let imageB = UIImage(named: "bigbutton")    let imageVIEw : UIImageVIEw = UIImageVIEw(frame: CGRectMake(0,300,300))    imageVIEw.image = imageB;    leftCAV.addSubvIEw(imageVIEw)    leftCAV.addSubvIEw(labelTitle)    leftCAV.addSubvIEw(labelSubTitle)    vIEw.leftCalloutAccessoryVIEw = leftCAV;    vIEw.rightCalloutAccessoryVIEw = leftCAV2;}

是否有机会使VIEw更大我尝试改变左右标注配件视图的尺寸但到目前为止没有成功.

解决方法 如果您只对更改注释标注的高度感兴趣,这是一种简单的方法.我只是将高度提高到200个单位.

func mapVIEw(mapVIEw: MKMapVIEw,vIEwForAnnotation annotation: MKAnnotation) -> MKAnnotationVIEw? {    if annotation is MKUserLocation {        return nil    }    let reuseID = "pin"    var pinVIEw = mapVIEw.dequeueReusableAnnotationVIEwWithIDentifIEr(reuseID) as? MKPinAnnotationVIEw    if pinVIEw == nil {        pinVIEw = MKPinAnnotationVIEw(annotation: annotation,reuseIDentifIEr: reuseID)        pinVIEw!.canShowCallout = true        pinVIEw!.animatesDrop = true        pinVIEw!.pinTintcolor = UIcolor.blackcolor()    }     pinVIEw!.detailCalloutAccessoryVIEw = self.configureDetailVIEw(pinVIEw!)    return pinVIEw}func configureDetailVIEw(annotationVIEw: MKAnnotationVIEw) -> UIVIEw {    let snapshotVIEw = UIVIEw()    let vIEws = ["snapshotVIEw": snapshotVIEw]    snapshotVIEw.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:[snapshotVIEw(200)]",options: [],metrics: nil,vIEws: vIEws))    //do your work     return snapshotVIEw}
总结

以上是内存溢出为你收集整理的ios – 如何更改注释标注窗口Swift的高度全部内容,希望文章能够帮你解决ios – 如何更改注释标注窗口Swift的高度所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1003759.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存