在我的 Mapview 中,我有 sum 注释,annontion 有一个按钮,可以将我发送到另一个 View 以获取有关此注释的更多详细信息
我的代码是
myAnnotation *myAnn = (myAnnotation *)annotation;
UIButton *discloseButton = [UIButton buttonWithType: UIButtonTypeDetailDisclosure];
[discloseButton addTarget: self action: @selector(showInfo forControlEvents: UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = discloseButton;
UIImageView *leftIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:myAnn.image]];
UIImage *pinImage = [UIImage imageNamed"pointer.png"];
[annotationView setImage:pinImage];
annotationView.leftCalloutAccessoryView = leftIconView;
return annotationView;
和
-(IBAction)showInfoid)sender
{
[self performSegueWithIdentifier"aa" sender:sender];
}
// envoie des données vers la detail d'une mission
- (void)prepareForSegueUIStoryboardSegue *)segue senderid)sender
{
if ([[segue identifier] isEqualToString"aa"])
{
DetailViewController *detailviewcontroller = [segue destinationViewController];
detailviewcontroller.DetailModal = @[@"aa",@"aaa",@"aaa"];
}
}
如何通过单击按钮发送对象注释以填充我的表格 detailviewcontroller.DetailModal ?
您可以将所有数据发送到格式化字符串并在 prepareForSegue
这样的代码
myAnnotation *myAnn = (myAnnotation *)annotation;
UIButton *discloseButton = [UIButton buttonWithType: UIButtonTypeDetailDisclosure];
[discloseButton addTarget: self action: @selector(showInfo forControlEvents: UIControlEventTouchUpInside];
NSString *detail = [NSString stringWithFormat"%@::%@::%@::%@::%@::%@::%@::%@::%@::%@::%@"
,myAnn.title,myAnn.description,myAnn.Latitude,myAnn.longitude,myAnn.image,myAnn.type,myAnn.ville,myAnn.point,myAnn.nombreDeVisite,myAnn.nbVTotal,myAnn.idMission];
discloseButton.accessibilityHint = detail;
annotationView.rightCalloutAccessoryView = discloseButton;
在你的函数中prepareForSegue
- (void)prepareForSegueUIStoryboardSegue *)segue senderid)sender
{
if ([[segue identifier] isEqualToString"aa"])
{
UIButton *button = (UIButton *)sender;
NSArray* infos = [button.accessibilityHint componentsSeparatedByString: @"::"];
if ([infos count] > 1)
{
tit = [infos objectAtIndex:0];
description = [infos objectAtIndex:1];
Latitude = [infos objectAtIndex:2];
longitude = [infos objectAtIndex:3];
image = [infos objectAtIndex:4];
type = [infos objectAtIndex:5];
ville = [infos objectAtIndex:6];
point = [infos objectAtIndex:7];
nombreDeVisite = [infos objectAtIndex:8];
nbVTotal = [infos objectAtIndex:9];
idMission = [infos objectAtIndex:10];
}
DetailViewController *detailviewcontroller = [segue destinationViewController];
detailviewcontroller.DetailModal = @[tit,description,Latitude,longitude,image,type,ville,point,nombreDeVisite,nbVTotal,idMission];
}
}
关于ios - 在 mkMapView ios 中的单击按钮中发送对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24000279/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |