Google Places Picker SDK (не работает) Swift 4 - PullRequest
0 голосов
/ 13 декабря 2018

Я недавно решил создать приложение с помощью Maps SDK от Google, но проблема в том, что, когда я открываю контроллер представления, он позволяет мне нажимать только на первый элемент.Я не могу найти решение, используя только документацию Google.У кого-нибудь есть решение этой проблемы?

import UIKit
import GoogleMaps
import GooglePlaces
import GooglePlacePicker

class PlacePickerVC: UIViewController, CLLocationManagerDelegate, GMSMapViewDelegate, GMSAutocompleteViewControllerDelegate, UITextFieldDelegate {

let currentLocationMarker = GMSMarker()
var locationManager = CLLocationManager()

var local = ""
var morada = ""

override func viewDidLoad() {
    super.viewDidLoad()
    self.title = "Teste"

    locationManager.delegate = self
    locationManager.requestWhenInUseAuthorization()
    locationManager.startUpdatingLocation()
    locationManager.startMonitoringSignificantLocationChanges()

    let config = GMSPlacePickerConfig(viewport: nil)
    let placePicker = GMSPlacePickerViewController(config: config)
    placePicker.delegate = self

    present(placePicker, animated: true, completion: nil)
}


// Handle the user's selection.
func viewController(_ viewController: GMSAutocompleteViewController, didAutocompleteWith place: GMSPlace) {
    //Display the places but only show
    print("Place name: \(place.name)")
    print("Place address: \(place.formattedAddress)")
    print("Place attributions: \(place.attributions)")
    dismiss(animated: true, completion: nil)
}

func viewController(_ viewController: GMSAutocompleteViewController, didFailAutocompleteWithError error: Error) {
    // TODO: handle the error.
    print("Error: ", error.localizedDescription)
}

// User canceled the operation.
func wasCancelled(_ viewController: GMSAutocompleteViewController) {
    dismiss(animated: true, completion: nil)
}

}

extension PlacePickerVC : GMSPlacePickerViewControllerDelegate {
func placePicker(_ viewController: GMSPlacePickerViewController, didPick place: GMSPlace) {
    print("Place name \(place.name)")
}

func placePicker(_ viewController: GMSPlacePickerViewController, 
didFailWithError error: Error) {
    // In your own app you should handle this better, but for the demo we are just going to log
    // a message.
    NSLog("An error occurred while picking a place: \(error)")
}

func placePickerDidCancel(_ viewController: GMSPlacePickerViewController) {
    // Dismiss the place picker, as it cannot dismiss itself.
    //viewController.dismiss(animated: true, completion: nil)
    print("No place selected")
}
}

Нельзя нажимать номера 1 2 и 3.

...