使用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
百度地图使用的也是苹果本身的定位实现,所以应该也需要实现新的授权方式.
但是用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 ([[[UIDevice currentDevice] systemVersion] doubleValue] > 8.0)
{
//设置定位权限 仅ios8有意义
[self.locationManager requestWhenInUseAuthorization];// 前台定位
//[self.locationManager requestAlwaysAuthorization];// 前后台同时定位
}
// 判断定位操作是否被允许
if([CLLocationManager locationServicesEnabled]) {
self.locationManager.delegate = self;
[self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
}
// 开始定位
[self.locationManager startUpdatingLocation];