ios8 地图定位失败解决办法

来源:互联网 发布:阿里云服务器8080端口 编辑:程序博客网 时间:2024/05/07 09:56

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

0 0
原创粉丝点击