Google自动填充广告国家/地区过滤器无法在iOS中使用

时间:2016-05-12 10:53:49

标签: ios swift google-maps google-places-api

let autocompleteController = GMSAutocompleteViewController()
autocompleteController.autocompleteFilter?.country = "AU"
autocompleteController.delegate = self
self.presentViewController(autocompleteController, animated: true, completion: nil)

我只需要过滤澳大利亚的数据,因此我想按国家/地区过滤数据。

2 个答案:

答案 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;