//*********************************创建地图视图8步骤***********************************************
1,代理<MKMapViewDelegate>
2.地理编码属性
@property (nonatomic, strong) CLGeocoder *geocoder;
3,地图视图属性
@property (nonatomic, strong) MKMapView *mapView;
4,位置管理属性
@property (nonatomic, strong) CLLocationManager *manager;
5,创建地图视图
_mapView =[ [MKMapView alloc] initWithFrame:[UIScreen mainScreen].bounds];
6,创建位置管理者
_manager = [CLLocationManager new];
//iOS8以后
7,[self.manager requestWhenInUseAuthorization];//询问用户是否同意定位
//假设用户同意
8,self.mapView.userTrackingMode = MKUserTrackingModeFollow;
//设置代理
9,self.mapView.delegate = self;
本文详细介绍了创建地图视图的八个步骤,包括代理MKMapViewDelegate、地理编码、地图视图及位置管理属性的设置、创建地图视图与位置管理者等,并提供了iOS 8之后的用户授权请求方式。
2849

被折叠的 条评论
为什么被折叠?



