MKAnnonationView 点击问题

发布于 2024-12-05 04:12:38 字数 382 浏览 2 评论 0原文

我想通过点击 MKMapView 上的 MKAnnotationView 导航到下一堂课。我该如何做到这一点,请为此提供一些示例代码。

我已经完成了这段代码..解释如下..

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

一个问题是,当单击一个项目时,此方法会调用,它将导航到其他类,但当我回来并再次点击同一项目时,此方法不会被调用。

请帮我解决这个问题...

提前致谢...

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 another 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...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天赋异禀 2024-12-12 04:12:38

您需要实现此方法:-

编辑:-

您需要实现以下方法。

 - (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) 注释 方法

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文