我在 ios 中使用 Google 自动完成 placekicker。它向我展示了具有本机设计的控制器。我想自定义它的导航栏颜色。但我无法做到。下面是代码
let autocompleteController = GMSAutocompleteViewController()
autocompleteController.tintColor = UIColor.red
autocompleteController.navigationController?.navigationBar.barTintColor = Constant.AppColor.navigationColor
autocompleteController.delegate = self
self.present(autocompleteController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
pod尝试使用GoogleMaps
来源' https://github.com/CocoaPods/Specs.git '
平台:ios,'8.1'
pod'GoogleMaps'
在两个步骤中检查GoogleMaps,示例(1)中的一个包含更多标题,如GMSAutocompleteTableDataSource.h
他们为什么不同?样本中的那个似乎是一个更好的版本,但pods给出的那个不是最新版本?它甚至不在更改日志中
我在我的iOS项目中使用了Google Places API的GMSAutoCompleteViewController。
今天突然,我的GMSAutoCompleteViewController继续给我错误“无法加载搜索结果”。
我已经使用新的API密钥重新生成了我的API密钥。我已经尝试了所有方法,但是仍然有些方法不起作用。
我正在使用Objective-C。有人可以帮忙吗?
码
GMSAutocompleteViewController *acController = [[GMSAutocompleteViewController alloc] init];
acController.delegate = self;
[self.navigationController pushViewController:acController animated:YES];
Run Code Online (Sandbox Code Playgroud)
委托方法
- (void)viewController:(GMSAutocompleteViewController *)viewController
didAutocompleteWithPlace:(GMSPlace *)place {
// Do something with the selected place.
NSLog(@"Place name %@", place.name);
NSLog(@"Place address %@", place.formattedAddress);
NSLog(@"Place attributions %@", place.attributions.string);
NSLog(@"Latitude = %.20f",place.coordinate.latitude);
NSLog(@"Longitude = %.20f",place.coordinate.longitude);
NSLog(@"Type = %@",place.types);
NSLog(@"Place ID = %@",place.placeID);
//[self dismissViewControllerAnimated:YES completion:nil];
[self.navigationController popViewControllerAnimated:YES];
/* Call and API in background to get the address according to the new LAT AND LONG …Run Code Online (Sandbox Code Playgroud) 我在swift项目中使用GMSAutocompleteFetcher来搜索地点.在这里,我使用pod安装'GooglePlaces''GooglePlacePicker''GoogleMaps',并在链接https://developers.google.com/places/ios-api/autocomplete#use_the_fetcher中编写所有内容, 但在textFieldDidChange中写入后,我得到的结果是它在委托方法中:
func didAutocomplete(with predictions: [GMSAutocompletePrediction]) {
let resultsStr = NSMutableString()
for prediction in predictions {
resultsStr.appendFormat("%@\n", prediction.attributedFullText)
}
Run Code Online (Sandbox Code Playgroud)
但在resultsStr得到的价值:
Ca{
GMSAutocompleteMatch = "<GMSAutocompleteMatchFragment: 0x608000223940>";
}lifornia{
}
Run Code Online (Sandbox Code Playgroud)
应该是"加利福尼亚"