2013-01-31 90 views
0

我已經使用右側的按鈕和左側的標籤創建了自定義註釋。定製註釋上的按鈕

它顯示很好,標籤文本正在改變完美,但由於某種原因,當我點擊按鈕,它不反應。我已經將IBAction連接到它並且它應該可以工作。但它只是不叫我的IBAction。

有沒有人有一個想法,爲什麼這個按鈕忽略我的觸摸?

感謝,

+0

plz post ur code .... – IronManGill

+0

我們不能猜測沒有任何代碼 –

回答

0
  (MKAnnotationView *)mapView:(MKMapView *)aMapView 
        viewForAnnotation:(id)ann 
     { 

     NSString *identifier = @」myPin」; 
     MKPinAnnotationView *pin = (MKPinAnnotationView *) 
     [aMapView dequeueReusableAnnotationViewWithIdentifier:identifier]; 
     if (pin == nil) { 
       pin = [[[MKPinAnnotationView alloc] initWithAnnotation:ann 
                  reuseIdentifier:identifier] 
         autorelease]; 
     } else { 
       pin.annotation = ann; 
     } 


     //---display a disclosure button on the right--- 
     UIButton *myDetailButton = 
     [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
     myDetailButton.frame = CGRectMake(0, 0, 23, 23); 
     myDetailButton.contentVerticalAlignment = 
     UIControlContentVerticalAlignmentCenter; 
     myDetailButton.contentHorizontalAlignment = 
     UIControlContentHorizontalAlignmentCenter; 

     [myDetailButton addTarget:self 
           action:@selector (checkButtonTapped:) 
        forControlEvents:UIControlEventTouchUpInside]; 

     pin.rightCalloutAccessoryView = myDetailButton; 
     pin.enabled = YES; 
     pin.animatesDrop=TRUE; 
     pin.canShowCallout=YES; 

     return pin; 
    } 



    -(void) checkButtonTapped:(id) sender 
     { 

     //---know which button was clicked; 
     // useful for multiple pins on the map--- 
     // UIControl *btnClicked = sender; 
     UIAlertView *alert = 
     [[UIAlertView alloc] initWithTitle:@」Your Current Location」 
             message :location 
             delegate:self 
          cancelButtonTitle:@」OK」 
          otherButtonTitles:nil]; 
     [alert show]; 
     [alert release]; 
     } 

我用這個代碼在我的項目,它爲我工作得很好,所以你可以試試這個。