Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS7+中的MKMapView调用错误;_Ios_Objective C_Mkmapview - Fatal编程技术网

iOS7+中的MKMapView调用错误;

iOS7+中的MKMapView调用错误;,ios,objective-c,mkmapview,Ios,Objective C,Mkmapview,只有在我稍微旋转地图后,annotationView才会打开详图索引。否则,它只移动地图并仅显示白色三角形。 这个bug只存在于iOS7中。在iOS 6中运行良好。 有什么帮助吗 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { PBAnnotation *pbAnnotation = (PBAnnotation *)annotatio

只有在我稍微旋转地图后,annotationView才会打开详图索引。否则,它只移动地图并仅显示白色三角形。
这个bug只存在于iOS7中。在iOS 6中运行良好。
有什么帮助吗

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
PBAnnotation *pbAnnotation = (PBAnnotation *)annotation;
MKAnnotationView *annotationView = nil;
if (annotation != _mapView.userLocation) {
    static NSString *ReusableViewId = @"PBAnnotation";
    annotationView = (MKAnnotationView *)[_mapView dequeueReusableAnnotationViewWithIdentifier:ReusableViewId];
    if (annotationView == nil) {
        annotationView = [[MKAnnotationView alloc] initWithAnnotation:pbAnnotation reuseIdentifier:ReusableViewId];
        annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        annotationView.canShowCallout = YES;

        switch (pbAnnotation.type) {
            case TypeHotel:
                annotationView.image = [UIImage imageNamed:@"pin-hotel"];
                break;
            case TypeRestaurant:
                annotationView.image = [UIImage imageNamed:@"pin-rest"];
                break;
            case TypeStore:
                annotationView.image = [UIImage imageNamed:@"pin-store"];
                break;
            case TypeTourSite:
                annotationView.image = [UIImage imageNamed:@"pin-site"];
                break;
            default:
                break;
        }

    }
}

return annotationView;
}
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释
{
PBAnnotation*PBAnnotation=(PBAnnotation*)注释;
MKAnnotationView*annotationView=nil;
如果(注释!=\u mapView.userLocation){
静态NSString*ReusableViewId=@“PBAnnotation”;
annotationView=(MKAnnotationView*)[\u mapView出列可重用AnnotationViewWith Identifier:ReusableViewId];
如果(注释视图==nil){
annotationView=[[MKAnnotationView alloc]initWithAnnotation:pbAnnotation reuseIdentifier:ReusableViewId];
annotationView.rightCalloutAccessoryView=[UIButton Button,类型:UIButtonTypedTailDisclosure];
annotationView.canShowCallout=是;
开关(pbAnnotation.type){
凯斯酒店:
annotationView.image=[UIImage ImageName:@“pin酒店”];
打破
箱式餐厅:
annotationView.image=[UIImage ImageName:@“固定销”];
打破
案例库:
annotationView.image=[UIImage ImageName:@“pin存储”];
打破
个案类型及地点:
annotationView.image=[UIImage ImageName:@“pin站点”];
打破
违约:
打破
}
}
}
返回注释视图;
}


如果您发现了错误,请将其报告给。同时,请显示您的
MKMapViewDelegate
方法,否则无法帮助找到解决方法。我不确定您的主要问题(可能您正在didSelectAnnotationView中执行一些特殊操作?),但您的图像设置逻辑有问题。代码仅在创建新视图时设置图像。如果视图已退出队列,则不会更新视图的注释属性或图像,这意味着注释可能显示错误的图像。缩放或平移地图时可能会出现此问题。此问题发生在初始加载时。在我旋转贴图之后,即使没有让注释排队,问题解决了。我的第一条评论是解释我在代码中看到的与视图重用无关的问题,该问题与您的主要问题无关。根据您最近的评论和关于标注的主要问题:您是否在最初加载标注时调用
selectAnnotation
?如果这是从后台线程执行的,则可能会导致此UI问题。