作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在MKAnnotation
中只有标题和副标题,我没有对注释添加任何控制。如何添加按钮?
最佳答案
尝试使用以下 map View 的委托(delegate)方法。您可以将右侧呼出附件 View 设置为按钮
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation{
MKAnnotationView *view = nil;
//MKPinAnnotationView *view=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"HotSpotsLoc"];
if(annotation !=mapView.userLocation){
view = (MKAnnotationView *)
[mapView dequeueReusableAnnotationViewWithIdentifier:@"identifier"];
if(nil == view) {
view = [[[MKAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:@"identifier"]
autorelease];
}
ParkPlaceMark *currPlaceMark = annotation;
NSLog(@"%i",currPlaceMark.position);
view.image = [UIImage imageNamed:@"pin.png"];
UIButton *btnViewVenue = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
view.rightCalloutAccessoryView=btnViewVenue;
view.enabled = YES;
view.canShowCallout = YES;
view.multipleTouchEnabled = NO;
//view.animatesDrop = YES;
}
return view;
}
关于iphone - 如何在XCode(iOS SDK)中添加按钮到注释 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6550201/
我是一名优秀的程序员,十分优秀!