ing*_*.am 10 iphone annotations objective-c mkmapview
我最近遇到过这个网站,我一直试图在我的呼叫中添加一个按钮(来自图像).
网站上的代码示例工作正常,但当我尝试将相同的代码添加到我的项目时,我得不到相同的结果.
显然我错过了一些东西,但似乎无法解决这个问题!
这是我的注释代码:
- (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;
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!:)
Hea*_*ers 15
那家伙正在使用自定义图像来模仿细节披露.您可以非常轻松地获得标准的详细信息:
[UIButton buttonWithType:UIButtonTypeDetailDisclosure];
Run Code Online (Sandbox Code Playgroud)
ton*_*ung 11
而不是像你在这里设置目标:
[advertButton addTarget:self action:@selector(showLinks:) forControlEvents:UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)
您可以使用默认委托:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21015 次 |
| 最近记录: |