高德开发者论坛
标题:
iOS一次定位和多次定位都失败
[打印本页]
作者:
amap_1391133028
时间:
2015-11-24 12:41
标题:
iOS一次定位和多次定位都失败
上周使用的还是iOS1.0.0SDK的一次定位,而且正常,这周突然发现定位出了问题,检查获取到的地理位置为空,错误信息是:Error Domain=AMapLocationErrorDomain Code=5 "取消" UserInfo={NSLocalizedDescription=取消}
更改为多次定位后
1.- (void)amapLocationManager
AMapLocationManager *)manager didFailWithError
NSError *)error;
2.- (void)amapLocationManager
AMapLocationManager *)manager didUpdateLocation
CLLocation *)location;
这两个代理方法都没走
屏幕快照 2015-11-24 下午12.40.27.png
(84.84 KB, 下载次数: 191)
下载附件
2015-11-24 12:40 上传
一次定位代码
作者:
mlfgaode
时间:
2015-11-26 17:53
你设置代理了吗?没设置self,怎么可能走代理方法。
作者:
chenjie_1986
时间:
2015-12-11 14:49
设置代理了吗?
作者:
uroaddev
时间:
2015-12-18 16:35
也遇到同样的问题,单次定位提示error为取消,但在使用delegate多次定位,有写delegate,没有回调。
作者:
appleliubo
时间:
2015-12-23 11:49
不要搞成局部局部变量,亲~
AMapLocationManager被释放的时候,自然会cancel掉~
作者:
amap_1355497143
时间:
2016-3-4 23:46
发帖都发不了 只能插楼了!!!!
关闭定位无效 v3.3.0
self.mapView.showsUserLocation = NO;没有作用
在两个界面都显示了地图 设置无效
至于sdk版本 我是直接pod安装的 没有写版本号,所以就是最新的版本
部分代码:
@property (nonatomic,weak) MAMapView * mapView;//地图
-(MAMapView *)mapView{
if (!_mapView) {
MAMapView * mapview = [[MAMapView alloc]initWithFrame:self.view.bounds];
mapview.delegate = self;
mapview.showsScale = NO;
_mapView.showsUserLocation = YES;
_mapView.userTrackingMode = MAUserTrackingModeNone;
_mapView = mapview;
_mapView.zoomLevel = 19;
_mapView.showsCompass = NO;
}
return _mapView;
}
在定位中 关闭无效
-(void)mapView
MAMapView *)mapView didUpdateUserLocation
MAUserLocation *)userLocation
updatingLocation
BOOL)updatingLocation
{
if(updatingLocation)
{
self.mapView.centerCoordinate = self.mapView.userLocation.location.coordinate;
//取出当前位置的坐标
NSLog(@"当前位置:latitude : %f,longitude: %f",userLocation.coordinate.latitude,userLocation.coordinate.longitude);
CLLocation * cll = [[CLLocation alloc] initWithLatitude:self.mapView.userLocation.location.coordinate.latitude longitude:self.mapView.userLocation.location.coordinate.longitude];
CLGeocoder *clGeoCoder = [[CLGeocoder alloc] init];
[clGeoCoder reverseGeocodeLocation:cll completionHandler: ^(NSArray *placemarks,NSError *error) {
CLPlacemark *placeMark = [placemarks firstObject];
NSDictionary *addressDic=placeMark.addressDictionary;
// NSString *state=[addressDic objectForKey
"State"];//省
self.city =[addressDic objectForKey
"City"];//市
// NSString *subLocality=[addressDic objectForKey
"SubLocality"];//区
// NSString *street=[addressDic objectForKey
"Street"];//街道
self.mapView.showsUserLocation = NO;
}];
}
}
望解决!!!没辙了 不然也不会这个点发!!!!!
作者:
chevalier528
时间:
2016-3-7 10:43
定位结束以后 断点试一下self.mapView.showsUserLocation = NO;有调用么?
作者:
amap_1831751680
时间:
2016-4-26 21:43
楼主, 问题解决了吗., 我的一次定位, 第一次定位成功, 后来的同样的代码都没有成功
作者:
amap_1370274734
时间:
2017-8-1 16:02
请问大神怎样才能手机号码基站定位?
欢迎光临 高德开发者论坛 (https://lbsbbs.amap.com/)
Powered by Discuz! X3.2