##LH_CLLocationManager.h的封裝 -1 具體功能git
/** * 定位管理者對象 * * @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 使用方法post
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 注意點 code
-5 具體使用請參看代碼(若有疑問,歡迎進羣479192251討論,或者博客留言看到會及時回覆的)對象