CLLocationManager中文注释

来源:互联网 发布:加泰罗尼亚公投 知乎 编辑:程序博客网 时间:2024/05/29 10:53


/*

 *  CLLocationManager.h

 *  CoreLocation

 *

 *  把ios7以下受保护的属性,方法都去掉

 *

 */


#import <Foundation/Foundation.h>

#import <CoreLocation/CLAvailability.h>

#import <CoreLocation/CLLocation.h>

#import <CoreLocation/CLRegion.h>


/*

 *  CLDeviceOrientation

 *  

 *  Discussion:

 *      Specifies a physical device orientation, equivalent to UIDeviceOrientation.

 *      

 */

typedefNS_ENUM(int, CLDeviceOrientation) {   //设备方向

CLDeviceOrientationUnknown =0,

CLDeviceOrientationPortrait,  //螢幕直立

CLDeviceOrientationPortraitUpsideDown, //螢幕直立,上下顛倒

CLDeviceOrientationLandscapeLeft, //螢幕向左橫置

CLDeviceOrientationLandscapeRight, //螢幕向右橫置

CLDeviceOrientationFaceUp,   //螢幕朝上平躺

CLDeviceOrientationFaceDown  //幕朝下平躺

};


/*

 *  CLAuthorizationStatus

 *  

 *  Discussion:

 *      Represents the current authorization state of the application.

 *      

 */

typedefNS_ENUM(int, CLAuthorizationStatus) {  //设备认证状态

// User has not yet made a choice with regards to this application 用户还未选择

kCLAuthorizationStatusNotDetermined =0

kCLAuthorizationStatusRestricted, //限制

kCLAuthorizationStatusDenied, //拒绝

kCLAuthorizationStatusAuthorizedAlways NS_ENUM_AVAILABLE(NA,8_0), //总是允许,ios8后可用

kCLAuthorizationStatusAuthorizedWhenInUse NS_ENUM_AVAILABLE(NA,8_0),//程序使用期间允许, ios8后可用


// This value is deprecated, but was equivalent to the new -Always value.

kCLAuthorizationStatusAuthorized NS_ENUM_DEPRECATED(10_6, NA,2_0, 8_0, "Use kCLAuthorizationStatusAuthorizedAlways") = kCLAuthorizationStatusAuthorizedAlways

};



typedefNS_ENUM(NSInteger, CLActivityType) { //车辆用途

    CLActivityTypeOther =1,

    CLActivityTypeAutomotiveNavigation,// for automotive navigation 车辆导航

    CLActivityTypeFitness,// includes any pedestrian activities  步行导航

    CLActivityTypeOtherNavigation // for other navigation cases (excluding pedestrian navigation), e.g. navigation for boats, trains, or planes

};


@class CLLocation;

@class CLHeading;

@class CLBeaconRegion;

@protocol CLLocationManagerDelegate;


NS_CLASS_AVAILABLE(10_6,2_0)

@interface CLLocationManager :NSObject

{

@private

id _internal;

}



+ (BOOL)locationServicesEnabled __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0); //定位服务是否开启



+ (BOOL)headingAvailable __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0); //返回该设备是否支持磁力计计算方向。


+ (BOOL)significantLocationChangeMonitoringAvailable __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0);//返回重大位置改变监听是否可用。


//确定设备是否支持监测指定类型的地区。例如ibeacon功能

+ (BOOL)isMonitoringAvailableForClass:(Class)regionClass __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);



/*

 *     返回蓝牙信号范围服务是否可用。这是iOS 7新增的方法。 

 */

+ (BOOL)isRangingAvailable __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);


/*

 * 返回当前用户获取地理位置的授权状态

 */   

+ (CLAuthorizationStatus)authorizationStatus __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_2);


@property(assign, nonatomic) id<CLLocationManagerDelegate> delegate;


//车辆用途 By default, CLActivityTypeOther is used.

@property(assign,nonatomic) CLActivityType activityType __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);


// 当移动的距离达到该值,位置更新一次,单位是米,

@property(assign,nonatomic) CLLocationDistance distanceFilter;


//  位置精度 By default, kCLLocationAccuracyBest is used.

@property(assign, nonatomic) CLLocationAccuracy desiredAccuracy;


//设置iOS设备是否可暂停定位来节省电池的电量。

@property(assign,nonatomic) BOOL pausesLocationUpdatesAutomatically __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);



@property(readonly,nonatomic, copy)CLLocation *location;


/*

 *  headingFilter

 *  

 *  Discussion:

 *      Specifies the minimum amount of change in degrees needed for a heading service update. Client will not

 *      be notified of updates less than the stated filter value. Pass in kCLHeadingFilterNone to be

 *      notified of all updates. By default, 1 degree is used.

 */

@property(assign,nonatomic) CLLocationDegrees headingFilter __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);


/*

 *  headingOrientation

 *  

 *  Discussion:

 *      Specifies a physical device orientation from which heading calculation should be referenced. By default,

 *      CLDeviceOrientationPortrait is used. CLDeviceOrientationUnknown, CLDeviceOrientationFaceUp, and

 *      CLDeviceOrientationFaceDown are ignored.

 *      

 */

@property(assign,nonatomic) CLDeviceOrientation headingOrientation __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);


/*

 *  heading

 *  

 *  Discussion:

 *      Returns the latest heading update received, or nil if none is available.

 */

@property(readonly,nonatomic, copy) CLHeading *heading __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);


/*

 *  maximumRegionMonitoringDistance

 *  

 *  Discussion:

 *       the maximum region size, in terms of a distance from a central point, that the framework can support.

 *       Attempts to register a region larger than this will generate a kCLErrorRegionMonitoringFailure.

 *       This value may vary based on the hardware features of the device, as well as on dynamically changing resource constraints.

 */

@property (readonly,nonatomic) CLLocationDistance maximumRegionMonitoringDistance __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0);


/*

 *  monitoredRegions

 *  

 *  Discussion:

 *       Retrieve a set of objects for the regions that are currently being monitored.  If any location manager

 *       has been instructed to monitor a region, during this or previous launches of your application, it will

 *       be present in this set.

 */

@property (readonly,nonatomic, copy) NSSet *monitoredRegions __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0);


/*

 *  rangedRegions

 *

 *  Discussion:

 *       Retrieve a set of objects representing the regions for which this location manager is actively providing ranging.

 */

@property (readonly,nonatomic, copy) NSSet *rangedRegions __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);


/*

 *  requestWhenInUseAuthorization

 *

 *  Discussion:

 *      When +authorizationStatus == kCLAuthorizationStatusNotDetermined,

 *      calling this method will trigger a prompt to request "when-in-use"

 *      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, "when-in-use" authorization grants access to the user's

 *      location via -startUpdatingLocation/-startRangingBeaconsInRegion while

 *      in the foreground.  If updates have been started when going to the

 *      background, then a status bar banner will be displayed to maintain

 *      visibility to the user, and updates will continue until stopped

 *      normally, or the app is killed by the user.

 *

 *      "When-in-use" authorization does NOT enable monitoring API on regions,

 *      significant location changes, or visits, and -startUpdatingLocation will

 *      not succeed if invoked from the background.

 *

 *      When +authorizationStatus != kCLAuthorizationStatusNotDetermined, (ie

 *      generally after the first call) this method will do nothing.

 *

 *      If the NSLocationWhenInUseUsageDescription key is not specified in your

 *      Info.plist, this method will do nothing, as your app will be assumed not

 *      to support WhenInUse authorization.

 */

- (void)requestWhenInUseAuthorization __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_8_0);


/*

 *  requestAlwaysAuthorization

 *

 *  Discussion:

 *      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.

 */

- (void)requestAlwaysAuthorization __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_8_0);


/*

 *  startUpdatingLocation

 *  

 *  Discussion:

 *      Start updating locations.

 */

- (void)startUpdatingLocation;


/*

 *  stopUpdatingLocation

 *  

 *  Discussion:

 *      Stop updating locations.

 */

- (void)stopUpdatingLocation;


/*

 *  startUpdatingHeading

 *

 *  Discussion:

 *      Start updating heading.

 */

- (void)startUpdatingHeading __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);


/*

 *  stopUpdatingHeading

 *

 *  Discussion:

 *      Stop updating heading.

 */

- (void)stopUpdatingHeading __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);


/*

 *  dismissHeadingCalibrationDisplay

 *  

 *  Discussion:

 *      Dismiss the heading calibration immediately.

 */

- (void)dismissHeadingCalibrationDisplay __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);


/*

 *  startMonitoringSignificantLocationChanges

 *

 *  Discussion:

 *      Start monitoring significant location changes.  The behavior of this service is not affected by the desiredAccuracy

 *      or distanceFilter properties.  Locations will be delivered through the same delegate callback as the standard

 *      location service.

 *

 */

- (void)startMonitoringSignificantLocationChanges __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0);


/*

 *  stopMonitoringSignificantLocationChanges

 *

 *  Discussion:

 *      Stop monitoring significant location changes.

 *

 */

- (void)stopMonitoringSignificantLocationChanges __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0);


/*

 *  startMonitoringForRegion:desiredAccuracy:

 *

 *  Discussion:

 *      Start monitoring the specified region.  desiredAccuracy represents the distance past the border of the region at

 *      which the application would like to be notified that the region border has been crossed.  This is useful to prevent

 *      repeated notifications when the user is on the border of the region.  This value will be honored on a best-effort basis,

 *      and may not be respected if desiredAccuracy is large with respect to the size of the region, or if the device is not

 *      capable of providing the precision desired.

 *

 *      If a region of the same type with the same identifier is already being monitored for this application, it will be

 *      removed from monitoring.

 *

 *      This is done asynchronously and may not be immediately reflected in monitoredRegions.

 */

- (void)startMonitoringForRegion:(CLRegion *)region

                 desiredAccuracy:(CLLocationAccuracy)accuracy __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA,__IPHONE_4_0, __IPHONE_6_0);

/*

 *  stopMonitoringForRegion:

 *

 *  Discussion:

 *      Stop monitoring the specified region.  It is valid to call stopMonitoringForRegion: for a region that was registered

 *      for monitoring with a different location manager object, during this or previous launches of your application.

 *

 *      This is done asynchronously and may not be immediately reflected in monitoredRegions.

 */

- (void)stopMonitoringForRegion:(CLRegion *)region __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0);


/*

 *  startMonitoringForRegion:

 *

 *  Discussion:

 *      Start monitoring the specified region.

 *

 *      If a region of the same type with the same identifier is already being monitored for this application,

 *      it will be removed from monitoring. For circular regions, the region monitoring service will prioritize

 *      regions by their size, favoring smaller regions over larger regions.

 *

 *      This is done asynchronously and may not be immediately reflected in monitoredRegions.

 */

- (void)startMonitoringForRegion:(CLRegion *)region __OSX_AVAILABLE_STARTING(__MAC_TBD,__IPHONE_5_0);


/*

 *  requestStateForRegion:

 *

 *  Discussion:

 *      Asynchronously retrieve the cached state of the specified region. The state is returned to the delegate via

 *      locationManager:didDetermineState:forRegion:.

 */

- (void)requestStateForRegion:(CLRegion *)region __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);


/*

 *  startRangingBeaconsInRegion:

 *

 *  Discussion:

 *      Start calculating ranges for beacons in the specified region.

 */

- (void)startRangingBeaconsInRegion:(CLBeaconRegion *)region __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);


/*

 *  stopRangingBeaconsInRegion:

 *

 *  Discussion:

 *      Stop calculating ranges for the specified region.

 */

- (void)stopRangingBeaconsInRegion:(CLBeaconRegion *)region __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);


/*

 * allowDeferredLocationUpdatesUntilTraveled:timeout:

 *

 * Discussion:

 * Indicate that the application will allow the location manager to defer

 * location updates until an exit criterion is met. This may allow the

 * device to enter a low-power state in which updates are held for later

 * delivery. Once an exit condition is met, the location manager will

 * continue normal updates until this method is invoked again.

 *

 * Exit conditions, distance and timeout, can be specified using the constants

 * CLLocationDistanceMax and CLTimeIntervalMax, respectively, if you are

 * trying to achieve an unlimited distance or timeout.

 *

 * The CLLocationManagerDelegate will continue to receive normal updates as

 * long as the application remains in the foreground. While the process is

 * in the background, the device may be able to enter a low-power state for

 * portions of the specified distance and time interval. While in this

 * state, locations will be coalesced for later delivery.

 *

 * Location updates will be deferred as much as is reasonable to save

 * power. If another process is using location, the device may not enter a

 * low-power state and instead updates will continue normally. Deferred

 * updates may be interspersed with normal updates if the device exits and

 * re-enters a low-power state.

 *

 * All location updates, including deferred updates, will be delivered via

 * the delegate callback locationManager:didUpdateLocations:

 *

 * When deferred updates have ended, the manager will invoke the delegate

 * callback locationManagerDidFinishDeferredUpdates:withError:. An error

 * will be returned if the manager will not defer updates and the exit

 * criteria have not been met.

 */

- (void)allowDeferredLocationUpdatesUntilTraveled:(CLLocationDistance)distance

  timeout:(NSTimeInterval)timeout __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);


/*

 * disallowDeferredLocationUpdates

 *

 * Discussion:

 * Disallow deferred location updates if previously enabled. Any outstanding

 * updates will be sent and regular location updates will resume.

 */

- (void)disallowDeferredLocationUpdates __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);


/*

 *  deferredLocationUpdatesAvailable

 *

 *  Discussion:

 *      Returns YES if the device supports deferred location updates, otherwise NO.

 */

+ (BOOL)deferredLocationUpdatesAvailable __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);


@end


0 0
原创粉丝点击