2011-09-16 21 views
1

我想通過點擊MKMapView上的MKAnnotationView導航到下一個課程。我怎麼做這個PLZ給這個例子代碼。MKAnnonationView攻牙問題

我已經做到了這一點下面code..explained ..

- (void)mapView:(MKMapView *)mapView1 didSelectAnnotationView:(MKAnnotationView *)customAnnotationView 
{ 
     //Here Push to another view controller 
} 

的一個問題是,在一個項目,當點擊,這個方法調用,它會導航到其他類,但是當我回來,並再次點擊在同一個項目上這個方法沒有被調用。

請幫我解決我這個問題......

在此先感謝...

回答

2

你需要實現這個方法: -

編輯: -

你需要實施以下方法。

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view 
{ 
    NSLog(@"touch"); 
    [mapView deselectAnnotation:view animated:NO]; 
    firstVC *aa=[[[firstVC alloc]initWithNibName:@"firstVC" bundle:nil] autorelease]; 
    [[self navigationController] pushViewController:aa animated:YES]; 

} 

-(void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view 
{ 
    NSLog(@"notouch"); 
    firstVC *aa=[[[firstVC alloc]initWithNibName:@"firstVC" bundle:nil] autorelease]; 
    [[self navigationController] pushViewController:aa animated:YES]; 

} 

以前: -

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 
{  
    CompanyDetail *detail = [[CompanyDetail alloc] initWithNibName:@"CompanyDetail" bundle:nil];  
    [self.navigationController pushViewController:detail animated:YES]; 
} 

Make sure you do 

UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation方法

+0

此方法時,我點擊的MapView的任何註釋不獲取調用,u能plz幫助我解決這個問題 –

+0

這個方法當你點擊你的註釋的披露按鈕時被調用。當你顯示註釋註釋時,你是否添加了你的按鈕 – Gypsa

+0

我沒有添加任何泄露按鈕,但添加了圖像使用自定義註釋和點擊這個註解我想這樣做..可以幫我 –