我感谢所有答案。非常感谢您的参与。 我已经找了一段时间但找不到解决问题的方法......
我让餐厅用户设置了一个图钉,其中包括餐厅图片,文字标题(他们在设置图钉前正确写入),文本字幕(他们在设置图钉之前正确写入)以及信息按钮标注。
我想这样做,以便当用户按下信息按钮标注时,他/她被带到显示餐馆图片,餐馆名称,标题,副标题和名称的页面。此外,我还需要一个后退按钮,将用户带回第一个视图控制器中的地图视图。
所以会有很多不同的餐厅,我需要以某种方式将数据从第一个视图控制器的引脚传送到第二个视图控制器。
我目前在我的第一个视图控制器中有这个代码来显示注释
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation: (id<MKAnnotation>)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
MKPinAnnotationView *MyPin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"User"];
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
MyPin.rightCalloutAccessoryView = rightButton;
MyPin.draggable = NO;
MyPin.highlighted = YES;
MyPin.animatesDrop=TRUE;
MyPin.canShowCallout = YES;
UIImageView *myCustomImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CorgiRunner2 Final.png"]];
myCustomImage.image = profPic;
myCustomImage.frame = CGRectMake(0,0,31,31);
MyPin.leftCalloutAccessoryView = myCustomImage;
return MyPin;
}
按下第一个视图控制器中的标注后,如何显示餐厅的特定信息?另外,请记住我不知何故需要访问第一个视图控制器中的文本。
再次,提前谢谢你!
答案 0 :(得分:1)
-mapView:annotationView:calloutAccessoryControlTapped:
。然后,您可以使用annotationView.annotation.restaurant
来了解您拥有的餐厅。您可以告诉它在这里展示下一个视图控制器并传递该餐厅。