解決ios8 webView加載的地圖沒法定位問題

  本文轉載至http://www.cocoachina.com/bbs/read.php?tid-237825.html

 
 
1.在文件info.pilist 中 導入 NSLocationWhenInUseUsageDescription

//IOS8 新功能用戶開啓定位 
2.appDelegate中帶入  #import <CoreLocation/CoreLocation.h>


3.加入下面的語句
 CLLocationManager* location = [CLLocationManager new];
 [location requestAlwaysAuthorization]; 


再次運行軟件就能夠定位了。 
緣由以下:
scussion:
 *      When +authorizationStatus == kCLAuthorizationStatusNotDetermined,
 *      calling this method will trigger a prompt to request "always"
 *      authorization from the user.  If possible, perform this call in response
 *      to direct user request for a location-based service so that the reason
 *      for the prompt will be clear.  Any authorization change as a result of
 *      the prompt will be reflected via the usual delegate callback:
 *      -locationManager:didChangeAuthorizationStatus:.
 *
 *      If received, "always" authorization grants access to the user's
 *      location via any CLLocationManager API, and grants access to
 *      launch-capable monitoring API such as geofencing/region monitoring,
 *      significante location visits, etc.  Even if killed by the user, launch
 *      events triggered by monitored regions or visit patterns will cause a
 *      relaunch.
 *
 *      "Always" authorization presents a significant risk to user privacy, and
 *      as such requesting it is discouraged unless background launch behavior
 *      is genuinely required.  Do not call +requestAlwaysAuthorization unless
 *      you think users will thank you for doing so.
 *
 *      When +authorizationStatus != kCLAuthorizationStatusNotDetermined, (ie
 *      generally after the first call) this method will do nothing.
 *
 *      If the NSLocationAlwaysUsageDescription key is not specified in your
 *      Info.plist, this method will do nothing, as your app will be assumed not
 *      to support Always authorization.



大概意思就是說:IOS8 新增長了一個選項 ,若是要開啓定位這個隱私選項的話 須要在Pilist導入NSLocationWhenInUseUsageDescription,而後掉用  requestAlwaysAuthorization這個方法。 此方法執行後,當要執行定位功能的時候就會觸發一個詢問,詢問用戶是否使用定位功能,若是選擇是,則啓動定位功能,若是選擇否,則方法返回,下次還將繼續詢問用戶。

 
 
關鍵詞: iOS  ios8  UIwebView  定位  mapview定位
 
 

 
級別: 俠客
 
UID: 239860
精華: 
發帖: 67
可可豆: 233 CB
威望: 200 點
在線時間: 507(時)
註冊時間: 2013-08-28
最後登陸: 2015-01-20
 
沙發 :發表於: 2014-12-01 17:16   發自: Web Page
只看該做者        
 
 
 
 
NSLocationAlwaysUsageDescription 看了文檔,應該是這個key吧 
相關文章
相關標籤/搜索