老項目的#iPhone6與iPhone6Plus適配#iOS8無法開啟定位問題和#解決方案#

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   io   os   ar   strong   

本文永久地址為 http://www.cnblogs.com/ChenYilong/p/4020359.html,轉載請註明出處。iOS8的定位和推送的訪問都發生了變化,

下面是iOS7和iOS8申請定位許可權時的不同:

iOS7:?本文永久地址為?http://www.cnblogs.com/ChenYilong/p/4020359.html,轉載請註明出處。?iOS8:?本文永久地址為?http://www.cnblogs.com/ChenYilong/p/4020359.html,轉載請註明出處。我們知道蘋果在iOS8上對定位進行了大幅度最佳化,可以支援室內地圖,常去地點統計,樓層等。但是在iOS8上currentLocation是空的,導致定位失敗了。高德也定位失敗(原因可能是未對iOS8做適配),或者不會調用到定位之後的delegate方法中,然後我查看了一下手機上對應用的定位許可權介面,發現我的應用程式的訪問使用者的地理位置的許可權是空的,之後查了相關資訊,得到以下解決方案:1.在AppDelegate中或者其它設定CLLocationManager的控制器中:
聲明@property(nonatomic,strong)CLLocationManager*locationManager;實現中添加如下代碼[UIApplicationsharedApplication].idleTimerDisabled=TRUE;
???self.locationManager= [[CLLocationManageralloc]init];
???self.locationManager.delegate=self;???self.locationManager.desiredAccuracy=kCLLocationAccuracyBest;???if(IS_IOS8){
[???self.locationManagerrequestAlwaysAuthorization];???//NSLocationAlwaysUsageDescription
??? [self.locationManagerrequestWhenInUseAuthorization];???//NSLocationWhenInUseDescription}??? [self.locationManagerstartUpdatingLocation];在AppDelegate是這樣設定的:@interface AppDelegate()<CLLocationManagerDelegate>{??? UINavigationController *_navController;??? CLLocationManager????? *_locationmanager;}?@end?@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{??? [UIApplication sharedApplication].idleTimerDisabled = TRUE;?????? _locationmanager = [[CLLocationManager alloc] init];??? [_locationmanager requestAlwaysAuthorization];??????? //NSLocationAlwaysUsageDescription??? [_locationmanager requestWhenInUseAuthorization];???? //NSLocationWhenInUseDescription??? _locationmanager.delegate = self;}本文永久地址為?http://www.cnblogs.com/ChenYilong/p/4020359.html,轉載請註明出處。
2.並需要plist檔案中進行設定:設定方法:?在 info.plist裡加入:??? NSLocationWhenInUseDescription,允許在前台擷取GPS的描述??? NSLocationAlwaysUsageDescription,允許在後台擷取GPS的描述? 如:
?添加以上內容之後即可以進行定位服務,下面的一些問題#解決方案#也是如此:
  1. iOS8 高德地圖SDK MAMapView無法定位的問題(http://blog.csdn.net/johnzhjfly/article/details/39497751)
  2. iOS8 百度地圖SDK MAMapView無法定位的問題
  3. iOS8 Location not?accessible
  4. iOS8 MKMapView 代理無效問題
  5. Access the user‘s location on Today Extension?
  1. iOS8無法開啟定位問題
本文永久地址為?http://www.cnblogs.com/ChenYilong/p/4020359.html,轉載請註明出處。?? 擴充閱讀:
  1. iOS8 定位新增功能(http://blog.csdn.net/yongyinmg/article/details/39521523)
  2. http://blog.uniba.jp/post/91830563468/ios-8http://www.cocoachina.com/bbs/read.php?tid-217107.htmlhttp://www.cocoachina.com/ask/questions/show/87714http://9to5mac.com/2014/06/04/apple-improves-location-services-in-ios-8-with-when-in-use-mode-visit-monitoring/http://derjohng.doitwell.tw/6197/%E9%9B%BB%E8%85%A6%E9%A1%9E%E5%88%A5/%E8%BB%9F%E9%AB%94%E7%AD%86%E8%A8%98/ios8-%E4%B8%8B%E5%AE%9A%E4%BD%8D-cllocationmanager-%E7%9A%84%E6%94%B9%E8%AE%8A/http://www.cocoachina.com/ask/questions/show/113705/CLLocationManager%E8%8E%B7%E5%8F%96%E5%9C%B0%E5%9D%80%E5%81%8F%E5%B7%AE
??另外這是iOS8申請push許可權也變了,其api也變了?請注意,在此不做贅述.??

**************************************************************************

?

其他周邊問題可參考我的系列文章:<老項目的#iPhone6與iPhone6Plus適配# >(持續更新中)

系列文章:老項目的#iPhone6與iPhone6Plus適配#(持續更新中,更新日期2014年10月12日 星期日 )

列表如下:

?

1.老項目的#iPhone6與iPhone6Plus適配#LaunchImage適配

2.老項目的#iPhone6與iPhone6Plus適配#Icon適配

3.老項目的#iPhone6與iPhone6Plus適配#iOS8無法開啟定位問題記起#解決方案#

?4.老項目的#iPhone6於iPhone6Plus適配#iPhone6解析度與適配

5.iOS裝置螢幕像素總覽

6.#iPhone6與iPhone6Plus適配#如何在Xcode 6中建立 PCH 檔案

**************************************************************************


本文永久地址為?http://www.cnblogs.com/ChenYilong/p/4020359.html,轉載請註明出處。

老項目的#iPhone6與iPhone6Plus適配#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.