iOS 使用腾讯地图显示用户位置注意事项

来源:互联网 发布:手机如何投诉淘宝卖家 编辑:程序博客网 时间:2024/06/10 23:08

1. 向 target中info 添加  NSLocationWhenInUseUsageDescription,string 类型,值是描述为什么需要用户位置,这句话会出现在 提示用户是否允许app访问用户位置提示框中。

2. 在appdelegate.m 的 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
中添加

    //地图定位

    CLLocationManager* locationManager = [[CLLocationManageralloc]init];

    if ([[UIDevicecurrentDevice].systemVersionfloatValue] >= 8.0) {

        [locationManager requestWhenInUseAuthorization];

    }

3. 添加腾讯地图

    self.mapView = [[QMapView alloc] initWithFrame:self.view.frame];

   self.mapView.delegate =self;

   self.mapView.showsUserLocation =YES;

    //缩放级别

    _mapView.zoomLevel =13;

    [self.view addSubview:_mapView];



1 0
原创粉丝点击