大佬教程收集整理的这篇文章主要介绍了iphone – 单击DetailDesclosure按钮时,MKAnnotationView按下以查看控制器,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
- (void)mapView:(MKMapView *)mapView AnnotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; detailViewController.title = DictionarY[@"placeLatitude"] [self.navigationController pushViewController:detailViewController animated:YES]; }
我可以用这个推送到视图控制器,但我还没想出如何强制它从用于生成地图的JSON数组中拉出细节.我正在拉这样的数据来生成地图:
for (NSDictionary *Dictionary in array) { // retrieve latitude and longitude from the Dictionary entry LOCATIOn.latitude = [DictionarY[@"placeLatitude"] doubleValue]; LOCATIOn.longitude = [DictionarY[@"placeLongitude"] doubleValue]; //CAN I LOAD THE titlE/ID OF THE LOCATION HERE?
我知道我有点偏离目标.也许只是向正确的方向踢一脚可能有所帮助.谢谢!
- (void)mapView:(MKMapView *)mapView AnnotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { [self performSegueWithIdentifier:@"Details" sender:view]; }
显然,如果您要为不同的注释类型调用不同的segue,则可以检查与该视图关联的注释类型等.
当然,如果你想像往常一样将任何信息传递给prepareForSegue中的下一个场景.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"Details"]) { MKAnnotationView *AnnotationView = sender; [segue.desTinationViewController setAnnotation:AnnotationView.Annotation]; } }
如您所见,我将注释对象传递给下一个视图.如果JSON结构中有与每个注释关联的其他字段,则一个简单的解决方案是将属性添加到与要跟踪的每个字段关联的自定义视图中.只需转到.h作为注释自定义类并添加所需的属性.然后,当您创建自定义注释(要添加到地图)时,也可以设置这些属性.然后,当您将此注释传递给下一个视图控制器时,所有所需的属性都将在那里可用.
显然,如果您正在使用NIB,只需执行任何您想要的NIB等效实例化下一个视图控制器,设置您想要的任何属性,并推送到它或以模态方式呈现它,例如:
- (void)mapView:(MKMapView *)mapView AnnotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { DetailsViewController *controller = [[DetailsViewController alloc] initWithNibName:nil bundle:nil]; controller.Annotation = AnnotationView.Annotation; [self.navigationController pushViewController:controller animated:YES]; // or use presentViewController if you're using modals }
以上是大佬教程为你收集整理的iphone – 单击DetailDesclosure按钮时,MKAnnotationView按下以查看控制器全部内容,希望文章能够帮你解决iphone – 单击DetailDesclosure按钮时,MKAnnotationView按下以查看控制器所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。