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

最新文章

  1. cocoapods安装以及使用,安装过程中ruby版本过低
  2. CUDA2.3-原理之任意长度的矢量求和与用事件来测量性能
  3. iOS 中如何将View设置为圆角的矩形?
  4. 关于DateTime.Now.Ticks
  5. 【转载】Linux小白福利:《超容易的Linux系统管理入门书》(三)在虚拟机上安装Linux
  6. js禁止默认的右键菜单或出现自定义右键菜单
  7. centos 安装,配置memcached
  8. table不能遗露了tbody
  9. android 中ImageButton按下改变背景图片的效果
  10. FindPkgConfig----CMake的pkg-config模块
  11. Openlayers系列(一)关于地图投影的理解
  12. Django详细流程
  13. Mysql 常用调优命令总结
  14. js实现数字千分位
  15. URL some
  16. (转)st(state-threads) coroutine和stack分析
  17. 产环境部署node记录(三): centOS 7 mySQL和mongoDB的安装
  18. nginx实战四
  19. kettle步骤概览--清洗校验
  20. Tomcat 配置虚拟路径保存、访问图片

热门文章

  1. Redis实现之事件
  2. TCP/IP网络编程之多进程服务端(二)
  3. 【Python】函数参数类型及用法
  4. mysql插入、修改、删除
  5. MySQL基础2-创建表和主键约束
  6. 微信小程序--微信小程序tabBar不显示:缺少文件,错误信息:error:iconPath=
  7. ms sqlserver数据库主文件特别大怎么办
  8. 【转】Unity3d中制作Loading场景进度条所遇到的问题 LoadLevelAsync,AsyncOperation
  9. GDOI2018前夕 错误总结
  10. BZOJ4555 [Tjoi2016&amp;Heoi2016]求和 【第二类斯特林数 + NTT】