错误集-在IOS8中百度地图无法定位

来源:互联网 发布:会员积分软件免费版 编辑:程序博客网 时间:2024/06/04 19:35
使用xcode6以下的版本运行项目在IOS8系统中,百度地图是可以实现定位功能的.
但是用xcode6及以上版本就不行了,xcode6中的地图定位新增加了2个api:


- (void)requestWhenInUseAuthorization __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_8_0);  
- (void)requestAlwaysAuthorization __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_8_0);  

同时需要在
Info.plist中加入两个缺省没有的字段
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription
都设置成YES




百度地图使用的也是苹果本身的定位实现,所以应该也需要实现新的授权方式.

不知道百度什么时候出一个新的版本.


   //ios8

    if ([[[UIDevicecurrentDevice] systemVersion]doubleValue] > 8.0)

    {

        //设置定位权限ios8有意义

        [self.locationManagerrequestWhenInUseAuthorization];//前台定位

        //[self.locationManager requestAlwaysAuthorization];//前后台同时定位

    }

    // 判断定位操作是否被允许

    if([CLLocationManagerlocationServicesEnabled]) {


        self.locationManager.delegate =self;

        [self.locationManagersetDesiredAccuracy:kCLLocationAccuracyBest];

    }

    // 开始定位

    [self.locationManagerstartUpdatingLocation];


0 0
原创粉丝点击