您的位置:首页 > 移动开发 > IOS开发

ios8 地图定位失败解决办法

2014-11-18 14:57 288 查看
iOS8修改了位置设置里的内容,增加了一套状态(使用中可用/通常可用),所以以前的CLLcationManage的注册后, Delegate接口不响应了。   iOS8需要这么设置 

第一步     

location = [[CLLocationManager alloc] init];
location.delegate= self;
[locationrequestAlwaysAuthorization];

第二步 在Plist中追加下面两个字段 (必须有,最少一个,内容是系统ALert的文言,文言可为空) NSLocationWhenInUseDescriptionNSLocationAlwaysUsageDescription

第三步 有了新的Delegate方法。 

<pre name="code" class="objc">- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
switch (status)
{
case kCLAuthorizationStatusNotDetermined:
if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
[self.locationManager requestAlwaysAuthorization];
}
break;
default:
break;
}
}




附上调查过程 https://developer.apple.com/jp/devcenter/ios/library/documentation/LocationAwarenessPG.pdf  http://www.w3c.com.cn/ios8新特性之基于地理位置的消息通知uilocalnotification http://blog.uniba.jp/post/91830563468/ios-8 

转自http://www.cocoachina.com/bbs/read.php?tid=217107&page=1&toread=1#tpc
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: