7.6 Displaying Custom Pins on a Map View
来源:互联网 发布:芒果店淘宝首页模板 编辑:程序博客网 时间:2024/06/03 13:09
自定义pin
- (MKAnnotationView *)mapView:(MKMapView *)mapView
viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView *result = nil;
if ([annotation isKindOfClass:[MyAnnotationclass]] == NO)
{
return result;
}
if ([mapView isEqual:self.myMapView] ==NO)
{
/* We want to process this event only for the Map View
that we have created previously */
return result;
}
/* First typecast the annotation for which the Map View has fired this delegate message */
MyAnnotation *senderAnnotation = (MyAnnotation *)annotation;
/* Using the class method we have defined in our custom annotation class, we will attempt to get a reusable identifier for the pin we are about to create */
NSString *pinReusableIdentifier = [MyAnnotation
reusableIdentifierforPinColor:senderAnnotation.pinColor];
/* Using the identifier we retrieved above, we will attempt to reuse a pin in the sender Map View */
MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [mapViewdequeueReusableAnnotationViewWithIdentifier:pinReusableIdentifier];
if (annotationView == nil){
/* If we fail to reuse a pin, then we will create one */
annotationView =[[MKPinAnnotationViewalloc] initWithAnnotation:senderAnnotation
reuseIdentifier:pinReusableIdentifier];
/* Make sure we can see the callouts on top of each pin in case we have assigned title and/or subtitle to each pin */
annotationView.canShowCallout =YES;
}
UIImage *pinImage = [UIImageimageNamed:@"aa.jpg"];
NSLog(@"pingImage = %@",pinImage);
if (pinImage != nil){
annotationView.image = pinImage;
}
result = annotationView;
return result;
}
其他的同前一节
输出
- 7.6 Displaying Custom Pins on a Map View
- 7.4 Displaying Pins on a Map View
- 7.5 Displaying Pins with Different Colors on a Map View
- JavaFTP - Displaying a custom file structure
- Creating a Custom View
- Popup custom view on current view
- 4.10 Displaying Context Menus on Table View Cells
- Creating custom View - Creating a View Class
- 2.14 Displaying an Image on a Navigation Bar
- android TV-Building a Details View,Displaying a Now Playing Card
- Custom video/camera overlay view on the iPhone
- Displaying a List
- custom view
- Custom View
- 7.1 Creating a Map View
- android-Updating Notifications,Using Big View Styles,Displaying Progress in a Notification
- Custom NAT and DHCP Configuration on a Windows Host
- Drawing a custom window on Mac OS X
- Postgresql数据库的一些字符串操作函数
- Linux 中断学习之小试牛刀篇
- LNMP下为Nginx目录设置访问验证的用户名密码
- 第6周作业1-闰年之循环判断(网络131黄宇倩)
- Win7系统的笔记本u盘数据如何恢复
- 7.6 Displaying Custom Pins on a Map View
- Java正则之贪婪匹配,惰性匹配
- python查看一个对象可用的方法
- ubuntu12.04输入法问题--安装多个输入法之后出现输入法经常不能调出
- nopcommerce笔记:添加数据表及相关配置
- 高新技术与光学测量仪
- StringBuffer的delete方法
- Android开机启动流程初探
- java并发编程之ThreadPoolExecutor