2017-12-04 11 views
1

Google의 웹 사이트에 Places API 자습서를 읽었으며 iOS 용 Places API가 사용 설정되었으며 API 키가 내 AppDelegate에 있다는 것을 두 번 확인했습니다. 내 수업에서 GMSPlacePickerViewControllerDelegate를 구현했습니다. 장소 선택 도구가 열리고 장소를 볼 수 있으며 그 위에 탭할 수 있으며 검색 할 수 있습니다. 이 화면에서 벗어날 수 없으며 취소 할 수 없으며 실제로 아무것도 선택하거나 위치를 반환 할 수 없습니다. 이것은 실제 장치와 시뮬레이터에서 동일합니다. 왜 작동하지 않으며 어떻게 작동시킬 수 있습니까?iOS 용 Google Places API로 취소 또는 선택 취소 허용 안함

@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") 
} 

답변

3

클래스에 GMSPlacePickerViewControllerDelegate 프로토콜을 구현하고 내가 GitHub의에 대한 몇 가지 프로젝트를 통해가는 내가 놓쳤다 어떤 운동을 한 후, 자신이 추가하려고했다 placePicker.delegate = self

+0

을 설정! 감사 – markeh21