无法将GMS映射显示在.xib文件UITableViewCell中

时间:2018-11-10 13:03:15

标签: uitableview gmsmapview

我在情节提要中有一个.xib文件,其中的UIView和该视图的IBOutlet连接到下面的文件。我确认调用awakeFromNib()并输入了currentLocation如果语句。另外,如果在情节提要中将UIView设置为GMSMapView,则会显示地图。不幸的是,即使下面的类有IBOutlet,我也无法与出现的地图进行交互。请注意,以下类扩展了扩展UITableViewCell的类。为什么地图没有出现在下面的类中?

import Foundation
import GoogleMaps
import GooglePlaces

class MapViewCell: HostViewCell {

    @IBOutlet weak var mapView: UIView!

    private var client = GMSPlacesClient()

    override func awakeFromNib() {
        super.awakeFromNib()

        initializeMap()
    }

    private func initializeMap() {
        if let currentLocation = LocationService.sharedLocation.currentLocation {
            let camera = GMSCameraPosition.camera(
                withLatitude: currentLocation.coordinate.latitude,
                longitude: currentLocation.coordinate.longitude,
                zoom: Constants.Numbers.ZOOM_LEVEL
            )
            let tempMapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
            tempMapView.isMyLocationEnabled = true
            tempMapView.delegate = self
            self.mapView.addSubview(tempMapView)
        }
    }
}

extension MapViewCell: GMSMapViewDelegate {

}

0 个答案:

没有答案