gpt4 book ai didi

iphone - 如何在XCode(iOS SDK)中添加按钮到注释 View

转载 作者:行者123 更新时间:2023-11-28 20:45:36 24 4
gpt4 key购买 nike

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/

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