我想用我的应用程序使用MKMapView的界面生成器来拉地图,但由于某种原因,它没有显示出来。另外我想通过点击我可以浏览我的iphone中存在的文件来添加一些按钮。如何在iPhone上的地图上放一个按钮
请为我提供详细的描述,因为我是新手。
谢谢,
我想用我的应用程序使用MKMapView的界面生成器来拉地图,但由于某种原因,它没有显示出来。另外我想通过点击我可以浏览我的iphone中存在的文件来添加一些按钮。如何在iPhone上的地图上放一个按钮
请为我提供详细的描述,因为我是新手。
谢谢,
你会想要添加一个注释到地图,然后提供一个自定义的视图。
要注释添加到地图上,采取在你的对象之一MKAnnotation协议及其协调属性设置为相应的纬度/经度位置。
接下来,您将使用MKMapView addAnnotation将注释添加到地图。
设置地图的委托财产到您的视图控制器,然后实现的MapView:viewForAnnotation:
当这个方法被调用,返回MKAnnotationView为您诠释。将MKAnnotationView的图片属性设置为您想要注解使用的任何图像(可能是按钮的图像?)。
如果您想知道何时选择了注释,则可以实施mapView:didSelectAnnotationView:。
您还可以设置使用MKAnnotationView的leftCalloutAccessoryView和rightCalloutAccessoryView性注释标注附件按钮。如果您这样做,则可以在用户通过执行mapView:annotationView:calloutAccessoryControlTapped:来选择标注按钮时作出响应。
其实我想要做的是,在我的应用中使用MKMapView的界面生成器拉地图,但由于某种原因它没有显示出来。另外我想通过点击我可以浏览我的iphone中存在的文件来添加一些按钮。 – Ashutosh 2010-07-22 13:49:14
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString *AnnotationViewID = @"annotationViewID";
annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];
if (annotationView == nil)
{
annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease];
}
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.image = [UIImage imageNamed:@"s11.png"];
annotationView.annotation = annotation;
[annotationView setEnabled:YES];
[annotationView setCanShowCallout:YES];
return annotationView;
}
使用此功能,您可以在pi的注释中添加按钮, – 2010-07-22 13:52:23
感谢您分享此信息,但我们如何通过拖放n拖放来通过界面生成器简单地拖拉地图。我做了同样的事情,但没有出现。 谢谢 – Ashutosh 2010-07-22 16:46:21
你不能简单地使用Interface Builder来删除一个引脚。 – esqew 2010-07-21 21:45:00