Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.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
MKPinAnnotationView rightCalloutAccessoryView不';t发送iOS7上的CalloutAccessoryControl_Ios_Ios7_Mkmapviewdelegate - Fatal编程技术网

MKPinAnnotationView rightCalloutAccessoryView不';t发送iOS7上的CalloutAccessoryControl

MKPinAnnotationView rightCalloutAccessoryView不';t发送iOS7上的CalloutAccessoryControl,ios,ios7,mkmapviewdelegate,Ios,Ios7,Mkmapviewdelegate,我正在尝试将我的一个应用程序更新到iOS7。问题是,在我的MKMapView上,当我点击一个pin时,它会显示Callout,但当单击rightCalloutAccessoryView时,它不会再向代理发送任何回调。因此,我无法再推送细节视图 它在iOS6上运行良好,在iOS7上不再运行。 以下是相关的代码: - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>

我正在尝试将我的一个应用程序更新到iOS7。问题是,在我的
MKMapView
上,当我点击一个pin时,它会显示
Callout
,但当单击
rightCalloutAccessoryView
时,它不会再向代理发送任何回调。因此,我无法再推送细节视图

它在iOS6上运行良好,在iOS7上不再运行。

以下是相关的代码:

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
    if ([annotation isKindOfClass:[MKUserLocation class]]) {
        return nil;
    }
    NSString * annotationIdentifier = nil;
    if ([annotation isKindOfClass:VPStation.class]) {
        annotationIdentifier = @"stationAnnotationIdentifier";
    }
    if (!annotation) {
        return nil;
    }
    MKPinAnnotationView * annotationView = [(MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier] retain];
    if(annotationView == nil) {
        annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
        annotationView.canShowCallout = YES;
        annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        annotationView.image = [UIImage imageNamed:@"MyAnnotationPin"];
        annotationView.centerOffset = CGPointMake(-10.0f, 0.0f);
    }
    annotationView.annotation = annotation;

    return [annotationView autorelease];
}

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
    if ([view.annotation isKindOfClass:VPStation.class]) {
        VPTotalDetailViewController * detailVC = [[VPTotalDetailViewController alloc] initWithStation:(VPStation *)view.annotation
                                                                                      andUserLocation:self.mapView.userLocation.coordinate];
        [self.navigationController pushViewController:detailVC animated:YES];
        [detailVC release];
    }
}
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{
if([annotation isKindOfClass:[MKUserLocation类]]){
返回零;
}
NSString*注释标识符=nil;
if([注释isKindOfClass:VPStation.class]){
annotationIdentifier=@“stationAnnotationIdentifier”;
}
如果(!注释){
返回零;
}
MKPinAnnotationView*annotationView=[(MKPinAnnotationView*)[mapView出列可重用AnnotationViewWithIdentifier:annotationIdentifier]保留];
如果(注释视图==nil){
annotationView=[[MKPinAnnotationView alloc]initWithAnnotation:annotation重用标识符:annotationIdentifier];
annotationView.canShowCallout=是;
annotationView.rightCalloutAccessoryView=[UIButton Button,类型:UIButtonTypedTailDisclosure];
annotationView.image=[UIImage ImageName:@“MyAnnotationPin”];
annotationView.centerOffset=CGPointMake(-10.0f,0.0f);
}
annotationView.annotation=注释;
返回[注释视图自动删除];
}
-(无效)地图视图:(MKMapView*)地图视图注释视图:(MKAnnotationView*)视图调用访问控制点击:(UIControl*)控制{
if([view.annotation iskindof类:VPStation.class]){
VPTotalDetailViewController*detailVC=[[VPTotalDetailViewController alloc]initWithStation:(VPStation*)view.annotation
andUserLocation:self.mapView.userLocation.coordinate];
[self.navigationController pushViewController:detailVC动画:是];
[VC发布详情];
}
}
根据
MKAnnotationView
类参考:

如果您指定的视图也是UIControl类的后代,您可以在点击控件时使用地图视图的委托来接收通知。如果它没有从UIControl下降,则您的视图负责处理其边界内的任何触摸事件

有什么比使用我自己的
UIView
子类来触摸并按下detailViewController更简单的方法吗?我应该等苹果公司修复这个错误吗?我相信这是一只虫子,不是吗


提前感谢

好吧,这里的问题是我在
MKMapView
上设置了一个
UIGestureRecognitor
(值得一提的是,它是一个自定义识别器,但我不相信这会改变任何东西),而这个手势识别器会消耗触摸,而触摸不会被转发到
calloutAccessoryControl
。注意,这种行为在iOS6和iOS7之间发生了变化。不过修复很简单,我添加了我的控制器作为识别器的代理(以前没有),并实现了
uigesturecognifizerdelegate
方法:

#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    if ([touch.view isKindOfClass:[UIControl class]]) {
        return NO;
    }
    return YES;
}

嗯。我的
calloutAccessoryControlTapped
很好。您是否100%确定注释类是
VPStation
?(如果
calloaccessorycontroltapped
方法的
if
语句,我可能会将
NSLog
/breakpoint放在该
语句之外。)唯一的问题是,我的右calloaccessory视图没有显示为详细信息,而是显示为一个信息按钮。顺便说一下,如果使用<代码>图像而不是PIN,你可能想考虑你的代码< McNoNoTyValue而不是<代码> MKPANANNATIONVIEW 。你是对的,我在一个仅用了<代码> MKMMAVIEW 和一个PIN的示例应用程序上尝试过,它工作得很好。我猜我的视图层次结构中一定有什么东西干扰了回调。我会再调查一些。谢谢,解决了!再次感谢。对我来说,同样的问题,我正在努力解决。你成功了吗?还是需要另一只手?谢谢。所有使用通配符识别器解决方案绕过苹果糟糕的MKUserTrackingMode实现的人最终都会来到这里。