2012-09-20 107 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

相關問題