ios 地图,系统升级为12后,进入地图,大头针全部默认展开问题,以及在选择不同距离的情况下,如何刷新地图的区域范围
2024-08-29 15:09:54
1.第一个问题,大头针在ios12,默认展开问题,需要设置大头针视图的默认选中属性为NO
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { //由于当前位置的标注也是一个大头针,所以此时需要判断,此代理方法返回nil使用默认大头针视图
if ([annotation isKindOfClass:[NearBrandAnnotation class]]) {
static NSString *key1=@"NearBrandAnnotation";
annotationView=[mapView dequeueReusableAnnotationViewWithIdentifier:key1];
//如果缓存池中不存在则新建
if (!annotationView) {
annotationView=[[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:key1];
annotationView.canShowCallout=YES;//允许交互点击
annotationView.calloutOffset=CGPointMake(, );//定义详情视图偏移量
UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(, , , )];
btn.backgroundColor = BLUECOLOR;
[btn setTitle:@"到这去" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(turnAction:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView=btn;//定义详情左侧视图
//注意:初始化必须设置为NO,否则会出现大片大头针默认展开副标题问题
annotationView.selected = NO;
objc_setAssociatedObject(btn, @"annotation",annotation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
//修改大头针视图
//重新设置此类大头针视图的大头针模型(因为有可能是从缓存池中取出来的,位置是放到缓存池时的位置)
annotationView.annotation=annotation;
annotationView.image=[UIImage imageNamed:@"brandPin"];//设置大头针视图的图片 return annotationView;
}else {
return nil;
}
}
//注意:初始化必须设置为NO,否则会出现大片大头针默认展开副标题问题
annotationView.selected = NO; 2.第二个问题,以及在选择不同距离的情况下,如何刷新地图的区域范围
- (void)setMapRegion{
if (_strLatitude&&_strLongitude&&mapView) { int distance;
if ([_distance intValue] == 0) {
distance = 1000*25;
}else{
distance = 1000*[_distance intValue];
}
CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(_strLatitude,_strLongitude);//纬度,经度
[mapView setRegion:MKCoordinateRegionMakeWithDistance(coords, distance, distance) animated:YES];
} }
by——zqk
最新文章
- cocoapods安装以及使用,安装过程中ruby版本过低
- CUDA2.3-原理之任意长度的矢量求和与用事件来测量性能
- iOS 中如何将View设置为圆角的矩形?
- 关于DateTime.Now.Ticks
- 【转载】Linux小白福利:《超容易的Linux系统管理入门书》(三)在虚拟机上安装Linux
- js禁止默认的右键菜单或出现自定义右键菜单
- centos 安装,配置memcached
- table不能遗露了tbody
- android 中ImageButton按下改变背景图片的效果
- FindPkgConfig----CMake的pkg-config模块
- Openlayers系列(一)关于地图投影的理解
- Django详细流程
- Mysql 常用调优命令总结
- js实现数字千分位
- URL some
- (转)st(state-threads) coroutine和stack分析
- 产环境部署node记录(三): centOS 7 mySQL和mongoDB的安装
- nginx实战四
- kettle步骤概览--清洗校验
- Tomcat 配置虚拟路径保存、访问图片
热门文章
- Redis实现之事件
- TCP/IP网络编程之多进程服务端(二)
- 【Python】函数参数类型及用法
- mysql插入、修改、删除
- MySQL基础2-创建表和主键约束
- 微信小程序--微信小程序tabBar不显示:缺少文件,错误信息:error:iconPath=
- ms sqlserver数据库主文件特别大怎么办
- 【转】Unity3d中制作Loading场景进度条所遇到的问题 LoadLevelAsync,AsyncOperation
- GDOI2018前夕 错误总结
- BZOJ4555 [Tjoi2016&;Heoi2016]求和 【第二类斯特林数 + NTT】