我通过这个 for 循环创建注释引脚:
UIButton *eventMore = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
for (i = 0; i < [results count]; i++) {
//NSLog(@"Result: %i = %@", i, results[i]);
//NSLog(@"%@",[[results objectAtIndex:i] objectForKey:@"long"]);
myAnn = [[CustomAnnotation alloc] init];
location.latitude = (double)[[[results objectAtIndex:i] objectForKey:@"lat"] doubleValue];
location.longitude = (double)[[[results objectAtIndex:i] objectForKey:@"long"] doubleValue];
myAnn.coordinate = location;
myAnn.title = [[results objectAtIndex:i] objectForKey:@"title"];
myAnn.subtitle = [[results objectAtIndex:i] objectForKey:@"strap"];
[eventMore addTarget:myAnn action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
[locations addObject:myAnn];
//NSLog(@"%i", [[results objectAtIndex:i] objectForKey:@"lat"]);
}
我想要做的是在注释的标题/描述右侧添加详细信息披露按钮,但是这不会添加一个,并且我为此找到的所有 tuts 都使用这种方法来做到这一点 - 但它不工作,有什么建议吗?
以及该操作的代码:
-(void)btnClicked:(id)sender{
UIAlertView *btnAlert = [[UIAlertView alloc] initWithTitle:@"title" message:@"msg" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil, nil];
[btnAlert show];
}