Iphone 在mkannotationview中替换calloutaccessoryview
在我的Iphone 在mkannotationview中替换calloutaccessoryview,iphone,iphone-sdk-3.0,mkmapview,Iphone,Iphone Sdk 3.0,Mkmapview,在我的viewForAnnotation委托中,我创建了一个MKAnnotationView,其中leftcallout附件作为信息按钮。点击info按钮时,我想用UIActivityIndicator替换它。因此,在calloutAccessoryTapped委托中,我写道 view.leftCalloutaccessoryView=[UIActivityIndicatorWithStyle:UIActivityIndicatorWhite] 详图索引附件似乎在更改,但视图似乎不会立即更新 当
viewForAnnotation
委托中,我创建了一个MKAnnotationView
,其中leftcallout附件
作为信息按钮。点击info按钮时,我想用UIActivityIndicator
替换它。因此,在calloutAccessoryTapped
委托中,我写道
view.leftCalloutaccessoryView=[UIActivityIndicatorWithStyle:UIActivityIndicatorWhite]代码>
详图索引附件似乎在更改,但视图似乎不会立即更新
当调用附件被隐藏(通过点击另一个pin)并重新打开时,我看到一个微调器。但除此之外,我没有
我也尝试调用了[view setNeedsdisplay]
和[view setNeedsLayout]
和[view LayoutSubview]
,但没有成功
有什么建议和建议吗? < P>我会考虑删除和重新添加注释。这似乎有点笨手笨脚,但可能有用。我也遇到了类似的问题——如果有一个图像与注释关联,我需要为LeftCallout AccessoryView显示一个图像。尝试在mapView:didSelectAnnotationView中进行设置,而不是在mapView:viewForAnnotation中进行设置
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)annotView
{
...
if(imgURL.length>1){
// set a thread that will load the image
// but don't set the leftCalloutAccessoryView until the image is loaded
dispatch_queue_t downloader = dispatch_queue_create("annotation image downloader",NULL);
dispatch_async(downloader, ^{
NSURL* photoURL = [NSURL URLWithString:imgURL];
NSData* photoData = [NSData dataWithContentsOfURL:photoURL];
UIImage* photoImage = [UIImage imageWithData:photoData];
dispatch_async(dispatch_get_main_queue(), ^{
annotView.leftCalloutAccessoryView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
[(UIImageView *) annotView.leftCalloutAccessoryView setImage:photoImage];
});
});
}
}