MKAnnonationView Tapping Problem
I want to navigate to next class through tap on MKAnnotationView on MKMapView. How can I do this plz give some sample code for this.
I had done this code..explained below..
- (void)mapView:(MKMapView *)mapView1 didSelectAnnotationView:(MKAnnotationView *)customAnnotationView
{
//Here Push to anoth开发者_如何学运维er view controller
}
One problem is that when clicking on one item, this method calls and It will navigate to other class but when I come back and again tap on the same item this method not called.
Please help me to solve me this problem...
Thanks in advance...
you need to implement this method:-
edited:-
you need to implement following method.
- (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];
}
previous:-
- (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];
in your
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
method
精彩评论