学习笔记-斯坦福iOS7-第十四课:UIApplication和MapKit


一. UIApplication
1. UIApplication *myApp = [UIApplication sharedApplication];
2. Network Activity Indicator
UIApplication 的属性:newWorkActivityIndicatorVisible;


二. 开始demo了。。。


三. Core Location
1. CLLocation
2. CLLocationManager
3. 创建CLLocationManager前,检测硬件是否支持,包括下面:
a. 是否授权,被限制(家长模式,企业)
   + (CLAuthorizationStatus)authorizationStatus;
b. 用户是否允许访问位置服务
   + (BOOL)locationServicesEnabled;
c. 表明设备能否报告基于significant location changges的更新
   + (BOOL)significantLocationChangeMonitoringAvailable;
d. 对某些设备 beacon的监听
   + (BOOL)isMonitoringAvailableForClass:(Class)regionClass;
e. 范围是否有效
   + (BOOL)isRangingAvailable;

4. 使用:
a. 设置精度和距离
b. 调用startUpdatingLocation
c. delegate 返回信息
- (void)locationManager:(CLLocationManager*)manager
    didUpdateLocations:(NSArray*)locations;

- (void)locationManager:(CLLOcationManager*)manager
       didFailWithError:(NSError*)error;
kCLErrorLocationUnknown //可能是暂时的,可以等待
kCLErrorDenied //用户拒绝使用接受更新
kCLErrorHeadingFailure  //局部磁干扰,等待一会


5. 在后台监视位置,非常非电量,除了跑步监视app,其他一般很少用,不过提供了2个非常节能的API,可以在后台或者前台都能监视到用户位置的移动,即使程序没有启动,唯一不足是需要很大距离才会更新。
- (void)startMonitoringSignificantLocationChanges;
- (void)stopMonitoringSignificantLocationChanges;


6. 进入,离开某个圆形区域时,通知
- (void)startMonitoringForRegion:(CLRegion *)region;
- (void)stopMonitoringForRegion:(CLRegion *)region; 
delegate:
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region;
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region;

- (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error; 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值