Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用UItableviewCell实现Google地图_Ios_Swift_Uitableview_Google Maps Sdk Ios - Fatal编程技术网

Ios 使用UItableviewCell实现Google地图

Ios 使用UItableviewCell实现Google地图,ios,swift,uitableview,google-maps-sdk-ios,Ios,Swift,Uitableview,Google Maps Sdk Ios,我试图在UItableviewCell组件中实现google地图。我这样做的方式是在原型单元中定义一个GMSMapView,然后使用dequeueReusableCell方法配置map单元。但是,我尝试应用的任何更改都会失败(例如添加标记、相机、缩放等)。有人知道关于这个问题的任何信息吗 代码参考: class UITenderInfoMapCell: UITableViewCell { @IBOutlet weak var view: UIView! @IBOutlet weak var s

我试图在UItableviewCell组件中实现google地图。我这样做的方式是在原型单元中定义一个GMSMapView,然后使用dequeueReusableCell方法配置map单元。但是,我尝试应用的任何更改都会失败(例如添加标记、相机、缩放等)。有人知道关于这个问题的任何信息吗

代码参考:

class UITenderInfoMapCell: UITableViewCell {

@IBOutlet weak var view: UIView!
@IBOutlet weak var subView: GMSMapView!

override func awakeFromNib() {

    super.awakeFromNib()
    self.initMap()

}



/**
    Init blank map when initializing a MapCell, waypoints, directions, etc can be loaded later.
**/
func initMap() {

    let camera = GMSCameraPosition.camera(withLatitude: 1.285, longitude: 103.848, zoom: 12)
    let mapView = GMSMapView.map(withFrame: .zero, camera: camera)
    self.subView = mapView


}

我和你一样为GMSMapView添加了一个插座,仅此而已。我跳过了您的
initMap()
方法

ViewController
cellForRowAt
中,它对我来说很好

let marker = GMSMarker(position: CLLocationCoordinate2D(latitude: 51.483682, longitude: -0.091991))
marker.map = cell?.subView

你的问题到底是什么?

我和你一样为GMSMapView添加了一个插座,仅此而已。我跳过了您的
initMap()
方法

ViewController
cellForRowAt
中,它对我来说很好

let marker = GMSMarker(position: CLLocationCoordinate2D(latitude: 51.483682, longitude: -0.091991))
marker.map = cell?.subView

您的问题到底是什么?

执行以下步骤将MapView添加到TableViewCell

  • 在自定义Tableviewcell中获取一个UIView,并将该UIView的类名命名为“GMSmapView”
  • 确保连接Mapview的委托方法
  • 在ViewController中,导入“GoogleMaps”和代理“GMSMapViewDelegate”
  • 为您创建的TableViewCell设置如下MapView插座:
  • 在“cellForRowAt”中添加以下代码

  • 注意:我在这里提供了一些额外的代码,用于使用“DynamicView”添加自定义标记。如果不想添加自定义标记,可以跳过这些代码。另外,不要忘记从google developer帐户为google maps配置所需设置,并向appdelegate添加相应的密钥,例如

    let key = "keep you key here"
    GMSServices.provideAPIKey(key)
    

    执行以下步骤将MapView添加到TableViewCell

  • 在自定义Tableviewcell中获取一个UIView,并将该UIView的类名命名为“GMSmapView”
  • 确保连接Mapview的委托方法
  • 在ViewController中,导入“GoogleMaps”和代理“GMSMapViewDelegate”
  • 为您创建的TableViewCell设置如下MapView插座:
  • 在“cellForRowAt”中添加以下代码

  • 注意:我在这里提供了一些额外的代码,用于使用“DynamicView”添加自定义标记。如果不想添加自定义标记,可以跳过这些代码。另外,不要忘记从google developer帐户为google maps配置所需设置,并向appdelegate添加相应的密钥,例如

    let key = "keep you key here"
    GMSServices.provideAPIKey(key)
    

    有些代码可能会有帮助,我们不会读心..我尝试应用的任何更改都会失败吗?你这是什么意思?您的应用程序是否崩溃或更改在UI中不可见?@Matt更改在UI中不可见,我只是一直得到一张空白地图。您是否通过安装pod来使用google map sdk@Dansome代码会很有帮助,我们不会读心..我尝试应用的任何更改都会失败吗?你这是什么意思?您的应用程序是否崩溃或更改在UI中不可见?@Matt更改在UI中不可见,我只是一直得到一张空白地图。您是否通过安装pod来使用google map sdk@丹