iOS 语音通话没有走回调代理,具体要怎么配置

如题所述

iOS8前使用CoreLocation定位
1、首先定义全局变量用记录CLLocationManager象引入CoreLocation.framework使用#import CoreLocation.h>
1

@property (nonatomic, strong) CLLocationManager *locationManager;

2、初始化CLLocationManager并始定位

self.locationManager = [[CLLocationManager alloc]init];
_locationManager.delegate = self;
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.distanceFilter = 10;
[_locationManager startUpdatingLocation];

3、实现CLLocationManagerDelegate代理
(1)获取位置数据返CLLocation数组般使用其

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *currLocation = [locations lastObject];
NSLog(@"经度=%f 纬度=%f 高度=%f", currLocation.coordinate.latitude, currLocation.coordinate.longitude, currLocation.altitude);
}

(2)获取用户位置数据失败调通知用户

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
if ([error code] == kCLErrorDenied)
{
//访问拒绝
}
if ([error code] == kCLErrorLocationUnknown) {
//获取位置信息
}
}

4、viewWillDisappear关闭定位

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[_locationManager stopUpdatingLocation];
}

iOS8使用CoreLocation定位
1、使用CoreLocation前需要调用函数【iOS8专用】:
iOS8定位进行些修改其包括定位授权CLLocationManager增加面两:
(1)始终允许访问位置信息
- (void)requestAlwaysAuthorization;
(2)使用应用程序期间允许访问位置数据
- (void)requestWhenInUseAuthorization;
示例:

self.locationManager = [[CLLocationManager alloc]init];
_locationManager.delegate = self;
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.distanceFilter = 10;
[_locationManager requestAlwaysAuthorization];//添加句
[_locationManager startUpdatingLocation];

2、Info.plist文件添加配置:
(1)NSLocationAlwaysUsageDescription
(2)NSLocationWhenInUseUsageDescription
温馨提示:答案为网友推荐,仅供参考
相似回答