Skip to content

使用block方式实现一行代码获取用户地理位置信息(定位)。

License

Notifications You must be signed in to change notification settings

iGhibli/SJLocationManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SJLocationManager

使用block方式实现一行代码获取用户地理位置信息(定位)。

Usage 使用方法:

  1. iOS8.0+先在info.plist中, 添加NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription定位权限。
  2. 获取用户位置调用如下方法:
	self.manager = [[SJLocationManager alloc] init];
	[self.manager getSJLocation:^(SJLocation *location, CLLocationManager *manager) {
		// 自己按需要自定义SJLocation位置信息Model
		// 若只需要获取一次位置,在此添加 [manager stopUpdatingLocation]; 即可。
		NSLog(@"---%@---%@---%@", location.longitudeStr, location.latitudeStr, location.timeStampStr);
		NSLog(@"---%@", manager);
	} failure:^(NSError *error, CLLocationManager *manager) {
		// 此处可根据定位失败原因判断定位定位权限问题,并提示用户打开权限
		NSLog(@"---error--- %@", error);
		NSLog(@"---%@", manager);
	}];
	
	

About

使用block方式实现一行代码获取用户地理位置信息(定位)。

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published