gpt4 book ai didi

iphone - 向 MKMapView 调出注释添加附件 View 按钮?

转载 作者:太空狗 更新时间:2023-10-30 03:25:03 24 4
gpt4 key购买 nike

我最近遇到了 this website我一直在尝试向我的标注 View 添加一个按钮(来自图像)。

网站示例中的代码工作得很好,但是当我尝试将相同的代码添加到我的项目时,我没有得到相同的结果。

显然我错过了一些东西,但我似乎无法解决这个问题!

这是我的注释代码:

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;

UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeCustom];
advertButton.frame = CGRectMake(0, 0, 23, 23);
advertButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
advertButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

[advertButton setImage:[UIImage imageNamed:@"button_right.png"] forState:UIControlStateNormal];
[advertButton addTarget:self action:@selector(showLinks:) forControlEvents:UIControlEventTouchUpInside];

annView.rightCalloutAccessoryView = advertButton;

annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
}

任何帮助将不胜感激! :)

最佳答案

那家伙正在使用自定义图像来模仿细节披露。实际上,您可以很容易地获得标准的详细信息披露:

[UIButton buttonWithType:UIButtonTypeDetailDisclosure];

关于iphone - 向 MKMapView 调出注释添加附件 View 按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1433067/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com