UIWebView开始定位权限
2017-07-28 本文已影响0人
iOS乐乐
#import <CoreLocation/CoreLocation.h>
<CLLocationManagerDelegate>
self.locationManager=[[CLLocationManager alloc]init] ;
self.locationManager.delegate=self;
[self.locationManager startUpdatingLocation];
self.locationManager.distanceFilter=kCLLocationAccuracyBest;
[self.locationManager requestWhenInUseAuthorization];
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
// 获取经纬度
NSLog(@"纬度:%f",newLocation.coordinate.latitude);
NSLog(@"经度:%f",newLocation.coordinate.longitude);
UIAlertView*alert=[[UIAlertView alloc]initWithTitle:[NSString stringWithFormat:@"%f",newLocation.coordinate.latitude] message:[NSString stringWithFormat:@"%f",newLocation.coordinate.longitude] delegate:self cancelButtonTitle:@"好的" otherButtonTitles:nil, nil];
[alert show];
// 停止位置更新
// [manager stopUpdatingLocation];
}
// 定位失误时触发
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"error:%@",error);
}
plist全新
Privacy - Location Usage Description 访问位置
Privacy - Location When In Use Usage Description 使用您的位置获取当前的位置信息,通过设置页面的隐藏位置功能可随时手动隐藏位置信息。
Privacy - Location Always Usage Description 使用您的位置获取当前的位置信息,通过设置页面的隐藏位置功能可随时手动隐藏位置信息。