Google API iOS 不允许我取消或 select
Google Places API for iOS not letting me cancel or select
我遵循了 Google 网站上的 Places API 教程,我仔细检查了 iOS 的 Places API 是否已启用,并且我的API 密钥在我的 AppDelegate 中。我确实在 class 中实现了 GMSPlacePickerViewControllerDelegate。 Places Picker 将打开,我可以查看地点,可以点击它们,还可以进行搜索。我无法离开这个屏幕,我无法取消,我实际上无法 select 任何东西或 return 一个位置。这在物理设备和模拟器上是一样的。为什么它不起作用,我怎样才能让它起作用?
@IBAction func selectLocationPressed(_ sender: Any) {
let config = GMSPlacePickerConfig(viewport: nil)
let placePicker = GMSPlacePickerViewController(config: config)
present(placePicker, animated: true, completion: nil)
}
// To receive the results from the place picker 'self' will need to conform to
// GMSPlacePickerViewControllerDelegate and implement this code.
func placePicker(_ viewController: GMSPlacePickerViewController,
didPick place: GMSPlace) {
// Dismiss the place picker, as it cannot dismiss itself.
viewController.dismiss(animated: true, completion: nil)
print("Place name \(place.name)")
print("Place address \(place.formattedAddress)")
print("Place attributions \(place.attributions)")
}
func placePickerDidCancel(_ viewController:
GMSPlacePickerViewController) {
// Dismiss the place picker, as it cannot dismiss itself.
viewController.dismiss(animated: true, completion: nil)
print("No place selected")
}
在您的 class 中实施 GMSPlacePickerViewControllerDelegate 协议并设置 placePicker.delegate = self
我遵循了 Google 网站上的 Places API 教程,我仔细检查了 iOS 的 Places API 是否已启用,并且我的API 密钥在我的 AppDelegate 中。我确实在 class 中实现了 GMSPlacePickerViewControllerDelegate。 Places Picker 将打开,我可以查看地点,可以点击它们,还可以进行搜索。我无法离开这个屏幕,我无法取消,我实际上无法 select 任何东西或 return 一个位置。这在物理设备和模拟器上是一样的。为什么它不起作用,我怎样才能让它起作用?
@IBAction func selectLocationPressed(_ sender: Any) {
let config = GMSPlacePickerConfig(viewport: nil)
let placePicker = GMSPlacePickerViewController(config: config)
present(placePicker, animated: true, completion: nil)
}
// To receive the results from the place picker 'self' will need to conform to
// GMSPlacePickerViewControllerDelegate and implement this code.
func placePicker(_ viewController: GMSPlacePickerViewController,
didPick place: GMSPlace) {
// Dismiss the place picker, as it cannot dismiss itself.
viewController.dismiss(animated: true, completion: nil)
print("Place name \(place.name)")
print("Place address \(place.formattedAddress)")
print("Place attributions \(place.attributions)")
}
func placePickerDidCancel(_ viewController:
GMSPlacePickerViewController) {
// Dismiss the place picker, as it cannot dismiss itself.
viewController.dismiss(animated: true, completion: nil)
print("No place selected")
}
在您的 class 中实施 GMSPlacePickerViewControllerDelegate 协议并设置 placePicker.delegate = self