Implementing custom markerInfoWindow in swift not working

时光怂恿深爱的人放手 提交于 2019-12-23 17:49:05

问题


I've been using the method posted below to display a custom info window, but whenever I run it, only the default window (with the title/snippet) shows up? I have created both an xib and swift file for the following method, and I was trying to implement it using standard function notation (i.e. mapView(mapView, markerInfoWindow:mapView.currentMarker), but that wasn't compiling (tried with and without the explicit implementation). Any ideas?

Thanks,

Jacob

func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! {
        var infoWindow = NSBundle.mainBundle().loadNibNamed("InfoWindow", owner: self, options: nil).first! as InfoWindow
        infoWindow.label.text = "\(marker.position.latitude) \(marker.position.longitude)"
        return infoWindow
 }

Contents of InfoWindow:

class InfoWindow: UIView {

    @IBOutlet var label: UILabel!
    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func drawRect(rect: CGRect) {
    // Drawing code
    }
    */

}

来源:https://stackoverflow.com/questions/32292330/implementing-custom-markerinfowindow-in-swift-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!