CustomInfoWindow错误

时间:2017-07-01 23:38:11

标签: ios

您好我正在尝试在Swift 3中为GMS标记创建自定义信息窗口。我在视图控制器中创建了一个子UI视图,并将其命名为CustomInfoWindow。然后我创建了一个新的Swift文件,其中类CustomInfoWindow为UIView,用于连接我的自定义信息窗口中的标签。我将把我的代码粘贴在底部。问题是sigabrt错误,但更具体地说 'NSInternalInconsistencyException',原因:'无法在bundle中加载NIB:'NSBundle(loaded)',名称为'CustomInfoWindow'' 这是我的代码:

import UIKit
import GoogleMaps

class ViewTwo: UIViewController, GMSMapViewDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6)
        let mapView = GMSMapView.map(withFrame: .zero, camera: camera)
        mapView.delegate = self
        mapView.isMyLocationEnabled = true
        self.view = mapView

        let marker = GMSMarker()
        marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20)
        marker.title = "Sydney"
        marker.isTappable = true
        marker.map = mapView

        // Do any additional setup after loading the view.
    }

    func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
        let infoWindow = Bundle.main.loadNibNamed("CustomInfoWindow", owner: self.view, options: nil)!.first! as! CustomInfoWindow
        infoWindow.title.text = marker.title
        return infoWindow
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

请帮助。

0 个答案:

没有答案