iOS8定位問題解決方案

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   io   os   使用   ar   

1、修改info  新增Key:NSLocationAlwaysUsageDescription和NSLocationWhenInUseUsageDescription,這兩個Key的值將分別用於描述應用程式始終使用和使用期間使用定位的說明,這些說明將顯示在使用者佈建中。info新增鍵值對如下:


應用程式說明參見:

2、CLLocationManager初始化iOS8CLLocationManager新增執行個體方法requestWhenInUseAuthorization和requestAlwaysAuthorization,需要在初始化時根據需要調用。

if([CLLocationManager locationServicesEnabled]){        self.locationManage = [[[CLLocationManager alloc] init] autorelease];        self.locationManage.delegate = self;        self.locationManage.distanceFilter = 200;        self.locationManage.desiredAccuracy = kCLLocationAccuracyBestForNavigation;//kCLLocationAccuracyBest;        if (SYSTEM_VERSION >= 8.0) {            //使用期間            [self.locationManage requestWhenInUseAuthorization];            //始終            //or [self.locationManage requestAlwaysAuthorization]        }    }

3、代理新增下面的代理方法:
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{    switch (status) {        case kCLAuthorizationStatusNotDetermined:            if ([self.locationManage respondsToSelector:@selector(requestAlwaysAuthorization)])            {                [self.locationManage requestWhenInUseAuthorization];            }            break;        default:        break;    }}




iOS8定位問題解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.