@SanMao
2015-08-05T16:30:22.000000Z
字数 1879
阅读 1709
定位/地图
MKMapView,专门用于地图显示userTrackingMode属性可以跟踪显示用户的当前位置mapViewType设置地图类型
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation;// 一个位置更改默认只会调用一次,不断监测用户的当前位置// 每次调用,都会把用户的最新位置(userLocation参数)传进来- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated;// 地图的显示区域即将发生改变的时候调用- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated;// 地图的显示区域已经发生改变的时候调用
@property (nonatomic, copy) NSString *title;// 显示在大头针上的标题@property (nonatomic, copy) NSString *subtitle;// 显示在大头针上的子标题@property (readonly, nonatomic) CLLocation *location;// 地理位置信息(大头针钉在什么地方)
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation;// 根据传进来的(id<MKAnnotation>)annotation参数创建并返回对应的大头针控件
地图上的大头针控件是MKAnnotationView
MKAnnotationView的属性
@property (nonatomic, strong) id <MKAnnotation> annotation;// 大头针模型@property (nonatomic, strong) UIImage *image;// 显示的图片@property (nonatomic) BOOL canShowCallout;// 是否显示标注@property (nonatomic) CGPoint calloutOffset;// 标注的偏移量@property (strong, nonatomic) UIView *rightCalloutAccessoryView;// 标注右边显示什么控件@property (strong, nonatomic) UIView *leftCalloutAccessoryView;// 标注左边显示什么控件
@property (nonatomic) MKPinAnnotationColor pinColor;// 大头针颜色@property (nonatomic) BOOL animatesDrop;// 大头针第一次显示时是否从天而降