【问题标题】:Navigate to another page based on the callout clicked根据点击的标注导航到另一个页面
【发布时间】:2012-05-02 10:42:03
【问题描述】:

嗨,我有 mapview 并显示两个带有标注的引脚,当单击第一个引脚标注时说它必须导航到 firstview 控制器,当单击第二个引脚标注时,它必须导航到第二个视图控制器如何检查条件。

【问题讨论】:

    标签: iphone navigation android-mapview callout


    【解决方案1】:

    在您的 Pin 图上添加披露按钮。为这些按钮分配标签,然后根据分配的标签简单地检查和导航。

    喜欢:

    在您的标注类(MKAnnotationView 的子类)中,在函数 - (id) initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier 中添加以下行

    UIButton *btn;
    btn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    btn.frame = CGRectMake(275,27 ,30, 30);
    [btn addTarget:self action:@selector(openDetail:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:btn];
    

    如果有帮助,请告诉我。

    openDetail:

     -(void)openDetail: (id)sender
     {
    
    UIButton *button = (UIButton *)sender;
    int tag = button.tag;
     if(tag = 1)
     {
       //open 1st Controller.
     }
     else if(tag == 2)
     { 
      //open 2nd Controller.
     } 
    
     }
    

    【讨论】:

    • 不,实际上我有两个条件在这里检查,当单击用户位置引脚时,它必须导航到一个页面,当单击剩余引脚时,它必须导航到另一个页面。
    • -(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 在这个方法中我必须检查点击哪个引脚的条件
    • 按照我的回答中的所有步骤,然后告诉我您的问题。
    • 调试所有进程并告诉我你在哪里卡住了?什么是制造问题?准确告诉我
    • 实际上我有一个引脚,当单击该用户位置时,它必须在第一页上导航,其余的应该导航到第二页。您所说的条件是仅导航到同一页面
    猜你喜欢
    • 1970-01-01
    • 2021-08-19
    • 2014-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-02
    • 2015-08-12
    相关资源
    最近更新 更多