2012-09-20 37 views
1

我有一个很大的问题。我已经分类MKAnnotationView并添加了三个UIImageViews每个与图像。注释在地图上看起来很好。但是,它们不捕获触摸事件。我已经尝试了self.userInteractionEnabledexclusiveTouch,但似乎没有任何工作。注解视图中的子视图不检测触摸事件

  • (ID)initWithAnnotation:(ID)注释reuseIdentifier:(的NSString *)reuseIdentifier {

    self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]; 
    self.frame = CGRectMake(0, 0, kWidth, kHeight); 
    
    
    UIImage *image = [UIImage imageNamed:@"geo-icon.png"]; 
    
    UIImageView * turbineView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(0.0, 0.0, image.size.width, image.size.height) ]; 
    
    UIImageView * mastroView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(20.0, 100.0, image.size.width, image.size.height) ]; 
    mastroView.image = image; 
    mastroView.userInteractionEnabled = NO; 
    mastroView.exclusiveTouch = NO; 
    
    
    [turbineView addSubview:mastroView]; 
    
    image = [UIImage imageNamed:@"turbine-noshadow.png"]; 
    propellerView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(4.0, 82.0, image.size.width, image.size.height) ]; 
    propellerView.image = image; 
    propellerView.userInteractionEnabled = NO; 
    propellerView.exclusiveTouch = NO; 
    [turbineView addSubview:propellerView]; 
    
    image = [UIImage imageNamed:@"arrow.png"]; 
    UIImageView * arrowView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(32.0, 114.0, image.size.width, image.size.height) ]; 
    arrowView.image = image; 
    arrowView.userInteractionEnabled = NO; 
    arrowView.exclusiveTouch = NO; 
    [turbineView addSubview:arrowView]; 
    
    image = [UIImage imageNamed:@"run-turbine.png"]; 
    UIImageView * stoprunView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(65.0, 155.0, image.size.width, image.size.height) ]; 
    stoprunView.image = image; 
    stoprunView.userInteractionEnabled = NO; 
    stoprunView.exclusiveTouch = NO; 
    [turbineView addSubview:stoprunView]; 
    turbineView.userInteractionEnabled = NO; 
    turbineView.exclusiveTouch = NO; 
    
    
    
    
    [self addSubview:turbineView]; 
    self.userInteractionEnabled = NO; 
    self.exclusiveTouch = NO; 
    self.opaque = NO; 
    
    [self rodar]; // 
    return self; 
    

}

+0

请张贴包含上下文视图的代码 – Dreen

+0

注解代表螺旋桨旋转通过动画的eolic涡轮机。每个UIImageView都有一部分涡轮机的图像。带螺旋桨图像的UIImageView旋转。这里是代码: – lnj

+0

有关于此的任何更新?我有同样的问题。 – digidigo

回答

0

使用MKMapViewDelegate的mapView:didSelectAnnotationView:当用户敲击检测而不是尝试与注释本身上的轻敲进行交互。

您可以计算出您选择了哪些注释,并从mapView:didSelect...采取相应措施。

+0

问题是mapView:didSelectAnnotationView没有被调用。 – lnj

相关问题