在iOS 9中,一旦我们按下后退按钮而没有在选择器视图上选择任何位置,GMSPlacePicker就会崩溃,同时适用于iOS 8。
错误
*** - [UIWindow _shouldAnimatePropertyWithKey:]:发送到解除分配的实例的消息
代码
@interface GMSViewController ()
@property(nonatomic,strong) GMSPlacePicker *placePicker;
@end
@implementation GMSViewController{}
- (instancetype)init {
if ((self = [super init])) {
CLLocationCoordinate2D southWestSydney = CLLocationCoordinate2DMake(-33.8659, 151.1953);
CLLocationCoordinate2D northEastSydney = CLLocationCoordinate2DMake(-33.8645, 151.1969);
GMSCoordinateBounds *sydneyBounds =
[[GMSCoordinateBounds alloc] initWithCoordinate:southWestSydney coordinate:northEastSydney];
GMSPlacePickerConfig *config =
[[GMSPlacePickerConfig alloc] initWithViewport:sydneyBounds];
_placePicker = [[GMSPlacePicker alloc] initWithConfig:config];
}
return self;}
- (void)viewDidLoad {
[super viewDidLoad];
UITextView *textView = [[UITextView alloc] initWithFrame:self.view.bounds];
textView.delegate = self;
textView.editable = NO;
[self.view addSubview:textView];
__weak UITextView *weakResultView = textView;
[_placePicker pickPlaceWithCallback:^(GMSPlace *place, NSError *error) {
UITextView *resultView = weakResultView;
if (resultView == nil) {
return;
}
if (place) {
NSMutableAttributedString *text =
[[NSMutableAttributedString alloc] initWithString:[place description]];
[text appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n\n"]];
[text appendAttributedString:place.attributions];
resultView.attributedText = text;
} else if (error) {
resultView.text =
[NSString stringWithFormat:@"Place picking failed with error: %@", error];
} else {
resultView.text = @"Place picking cancelled.";
}
}];}
有人可以帮忙吗?