iOS - 使用 GoogleMaps SDK 时出现 Segue 问题

标签 ios iphone swift google-maps google-maps-sdk-ios

我在使用 GoogleMapsSDK 时遇到一个奇怪的问题。在我看来,显示的 Google map 中嵌入了一个导航 Controller 。在导航栏上,我有一个已连接到新 View 的栏按钮。当按下按钮时,segue 很滞后并且不显示任何内容。

这是发生的事情:http://gph.is/2putLtQ

不确定问题是什么。我在没有实现 GoogleMapsSDK 的情况下也进行了相同的设置。

这是 GoogleMaps View Controller :

import UIKit
import GoogleMaps

class GoogleMapsViewController: UIViewController, CLLocationManagerDelegate, GMSMapViewDelegate {

    var locationManager = CLLocationManager()
    var tacoLocations = [TacoLocation]()
    var tacoLocationPlace_id :String!

    override func viewDidLoad() {
        super.viewDidLoad()

        self.locationManager = CLLocationManager()
        self.locationManager.delegate = self
        self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
        self.locationManager.distanceFilter = kCLDistanceFilterNone
        self.locationManager.requestWhenInUseAuthorization()
        self.locationManager.startUpdatingLocation()

        let lat = self.locationManager.location?.coordinate.latitude
        let lng = self.locationManager.location?.coordinate.longitude


        // creates the map and zooms the current user location, at a 15.0 zoom
        let camera = GMSCameraPosition.camera(withLatitude: lat!, longitude: lng!, zoom: 15.0)
        let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
        view = mapView

        for location in self.tacoLocations {

            let marker = GMSMarker()

            let lat = location.locationLat
            let lng = location.locationLng

            marker.position = CLLocationCoordinate2D(latitude: lat!, longitude: lng!)
            marker.title = location.name

            if location.open_now == false {
                marker.snippet = "\(location.vicinity!)\nClosed"
            } else if location.open_now == true {
                marker.snippet = "\(location.vicinity!)\nOpen"
            } else {

            }
            marker.userData = location

            marker.icon = UIImage(named: "taco_marker.png")
            marker.infoWindowAnchor = CGPoint(x: 0.5, y: 0.2)

            marker.map = mapView  
        }
        // enable my location dot
        mapView.isMyLocationEnabled = true
        mapView.delegate = self

    }

    //MARK: GMSMapViewDelegate

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

        customWindow.nameLabel.text = marker.title
        customWindow.addressLabel.text = marker.snippet

        return customWindow
    }

    func mapView(_ mapView: GMSMapView, didTapInfoWindowOf marker: GMSMarker) {

        let tacoLocation = marker.userData as! TacoLocation
        self.tacoLocationPlace_id = tacoLocation.place_id

        DispatchQueue.main.async {
            self.performSegue(withIdentifier: "MoreInfoSegue", sender: self)
        }
    }

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {


        if segue.identifier == "MoreInfoSegue" {


            let tabVC = segue.destination as! UITabBarController
            let moreInfoVC = tabVC.viewControllers?[0] as! MoreInfoViewController
            let reviewVC = tabVC.viewControllers?[1] as! ReviewViewController

            moreInfoVC.tacoLocationPlace_id = self.tacoLocationPlace_id
            reviewVC.tacoLocationPlace_id = self.tacoLocationPlace_id

        } else if segue.identifier == "ARSegue" {

            //segue to new view that is not working correctly.

        }

    }
}

第二个 View Controller 中唯一的东西是viewdidload。

非常感谢任何帮助!

最佳答案

我卸载了 google map pod,然后重新安装了它们。这解决了我的问题。一定是 xcode 的错误。

关于iOS - 使用 GoogleMaps SDK 时出现 Segue 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43376346/

相关文章:

ios - 可以确定其他 iPhone/iPad 应用程序的使用统计数据吗?

ios - Swift3:类型 numberformatter 没有成员 'currency style' ,swift3

ios - 如何防止在 safari 移动浏览器上缩放(滚动)?

iphone - 使用协议(protocol)和委托(delegate)在 View Controller 之间传递数据

swift - 处理初始化失败的正确方法

swift - init抛出异常时是否调用deinit?

ios - 带有overlayskscene Xcode Swift 的屏幕触摸Scenekit 导致应用程序崩溃

ios - 从核心数据中提取的数据不正确

ios - 如何在 Flutter 插件中覆盖 iOS App 生命周期

iphone - 如何使用 UISearchDisplayController/UISearchBar 过滤 NSFetchedResultsController (CoreData)