程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> ios-檢測用戶是否拒絕使用默認位置

ios-檢測用戶是否拒絕使用默認位置

編輯:編程綜合問答
檢測用戶是否拒絕使用默認位置

請問一下,檢測ios的用戶是否拒絕開啟默認位置,能實現麼?

我需要在實現檢測結果,然後根據他們的選擇顯示不同的視圖控制器。

請賜教,謝謝。

最佳回答:


假設你使用LocationManager,那麼在delegate中有個方法是

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

你來檢測這個error.code是什麼,具體參見apple官方文檔Core Location Constants Reference中CLError部分

enum {
kCLErrorLocationUnknown  = 0,         // location is currently unknown, but CL will keep trying
kCLErrorDenied,                       // CL access has been denied (eg, user declined location use)
kCLErrorNetwork,                      // general, network-related error
kCLErrorHeadingFailure,               // heading could not be determined
kCLErrorRegionMonitoringDenied,       // Location region monitoring has been denied by the user
kCLErrorRegionMonitoringFailure,      // A registered region cannot be monitored
kCLErrorRegionMonitoringSetupDelayed, // CL could not immediately initialize region monitoring
kCLErrorRegionMonitoringResponseDelayed, // While events for this fence will be delivered, delivery will not occur immediately
kCLErrorGeocodeFoundNoResult,         // A geocode request yielded no result
kCLErrorGeocodeFoundPartialResult,    // A geocode request yielded a partial result
kCLErrorGeocodeCanceled,              // A geocode request was cancelled
kCLErrorDeferredFailed,               // Deferred mode failed
kCLErrorDeferredNotUpdatingLocation,  // Deferred mode failed because location updates disabled or paused
kCLErrorDeferredAccuracyTooLow,       // Deferred mode not supported for the requested accuracy
kCLErrorDeferredDistanceFiltered,     // Deferred mode does not support distance filters
kCLErrorDeferredCanceled,             // Deferred mode request canceled a previous request

};
typedef NSInteger CLError;

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved