iOS苹果自带框架定位的封装block

##LH_CLLocationManager.h的封装 -1 具体功能

/**
*  定位管理者对象
*
*  @return 创建好的定位管理者对象
*/
+ (LH_CLLocationManager *)shareLocation;
/**
*  用于获取用户当前位置的block
*
*  @param locaiontBlock 返回的用户当前位置的Corrrdinate
*/
- (void) lh_getCurrentLocationCoordinate:(LocationCorrrdinateBlock) locationtBlock;
/**
*  获取定位到的城市的经纬度和详细地址
*
*  @param locaiontBlock 返回定位代码块
*  @param addressBlock  返回详细地址代码块
*/
- (void) lh_getCurrentLocationCoordinate:(LocationCorrrdinateBlock) locationtBlock  withAddress:(NSStringDetailAddressBlock) addressBlock;
/**
*  获取详细地址
*
*  @param addressBlock addressBlock description
*/
- (void)lh_getCurrentDetailAddress:(NSStringDetailAddressBlock)addressBlock;
/**
*  获取当前定位到所在国家
*
*  @param countryBlock 返回定位到所在国家代码块
*/
- (void)lh_getCurrentCountry:(NSStringCountryBlock)countryBlock;
/**
*  获取城市的省份
*
*  @param cityBlock 返回所在省份的block
*/
- (void)lh_getCurrentProvince:(NSStringProvinceBlock)provinceBlock;
/**
*  获取所在城市
*
*  @param cityBlock 返回所在城市的block
*/
-(void)lh_getCurrentCity:(NSStringCityBlock)cityBlock;
/**
*  获取所在城市的街道名
*
*  @param thoroughfareBlock 返回所在街道的block
*/
-(void)lh_getCurrentThoroughfare:(NSStringThoroughfareBlock)thoroughfareBlock;
/**
*  获取邮编
*
*  @param postalCode 邮编block
*/
-(void)lh_getCurrentPostalCode:(NSStringPostalCodeBlock)postalCode;

/**
*  定位失败回调的block
*
*  @param errorBlock errorBlock 错误代码块
*/
- (void)lh_getLocationError:(LocationErrorBlock) errorBlock;

-2 使用方法

1 -导入头文件“LH_CLLocationManager.h”

2 -实例化定位管理者的对象
   LH_CLLocationManager* manger=[LH_CLLocationManager shareLocation];

3 -如果定位成功后,调用block

-3 具体示例

[manger lh_getCurrentCity:^(NSString *cityString) {
NSLog(@"当前城市:%@",cityString);
}];

[manger lh_getCurrentCountry:^(NSString *countryString) {
NSLog(@"当前国家:%@",countryString);
}];

[manger lh_getCurrentProvince:^(NSString *provinceString) {
NSLog(@"当前省份:%@",provinceString);
}];

[manger lh_getCurrentThoroughfare:^(NSString *thoroughfareString) {
NSLog(@"当前街道:%@",thoroughfareString);
}];

[manger lh_getCurrentDetailAddress:^(NSString *detailAddressString) {
NSLog(@"当前详细地址:%@",detailAddressString);
}];

[manger lh_getCurrentPostalCode:^(NSString *postalCodeString) {
NSLog(@"当前邮政编码:%@",postalCodeString);
}];

[manger lh_getCurrentLocationCoordinate:^(CLLocationCoordinate2D locationCorrrdinate) {
NSLog(@"当前位置经纬度(%lf,%lf)",locationCorrrdinate.latitude,locationCorrrdinate.longitude);
}];

[manger lh_getCurrentLocationCoordinate:^(CLLocationCoordinate2D locationCorrrdinate) {
NSLog(@"======当前位置经纬度(%lf,%lf)",locationCorrrdinate.latitude,locationCorrrdinate.longitude);
} withAddress:^(NSString *detailAddressString) {
NSLog(@"------当前详细地址:%@",detailAddressString);

-4 注意点 注意点

-5 具体使用请参看代码(如有疑问,欢迎进群479192251讨论,或者博客留言看到会及时回复的)

转载于:https://my.oschina.net/iOSliuhui/blog/725645

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值