let autocompleteController = GMSAutocompleteViewController()
autocompleteController.autocompleteFilter?.country = "AU"
autocompleteController.delegate = self
self.presentViewController(autocompleteController, animated: true, completion: nil)
我只需要过滤澳大利亚的数据,因此我想按国家/地区过滤数据。
答案 0 :(得分:16)
默认情况下,autocompleteFilter属性为nil,因此行
autocompleteController.autocompleteFilter?.country = "AU"
什么都不做。这样做是这样的:
let filter = GMSAutocompleteFilter()
filter.country = "AU"
autocompleteController.autocompleteFilter = filter
答案 1 :(得分:1)
GMSAutocompleteViewController *controller = [[GMSAutocompleteViewController alloc]init];
GMSAutocompleteFilter *filter = [[GMSAutocompleteFilter alloc]init];
controller.delegate = self;
filter.country = @"IN";
controller.autocompleteFilter = filter;