每次用户点击 mkannotationPinView 顶部时,我都希望隐藏并启动活动指示器。
这是我的代码:
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
if (!self.activityIndicator) {
NSLog(@"error");
}
self.activityIndicator.hidden = NO;
[self.mapView addSubview:self.activityIndicator];
[self.activityIndicator startAnimating];
if ([view.leftCalloutAccessoryView isKindOfClass:[UIImageView class]]) {
UIImageView *imageView = (UIImageView *)(view.leftCalloutAccessoryView);
if ([view.annotation respondsToSelector:@selector(thumbnail)]) {
imageView.image = [view.annotation performSelector:@selector(thumbnail)];
}
}
[self.activityIndicator stopAnimating];
}
我也尝试过切换[self.mapView addSubview:self.activityIndicator];
, [self.view addSubview:self.activityIndicator];
但效果是一样的,没有出现在视图上。有什么问题???谢谢