ios tableView加载cell时有延时的操作 比如反地理编码

来源:互联网 发布:淘宝服务市场怎么投诉 编辑:程序博客网 时间:2024/06/06 23:23
获取到数据之后 
#pragma mark -- 获取狗狗设备信息列表- (void) getDogoptionalInfo {    UserManager *manger = [UserManager getUserManager];    if ([manger checkIsLogined] == NO){         [self.dogEpumentInfoArr removeAllObjects];        return;    }    if (_logOutState == YES) {       [self.dogEpumentInfoArr removeAllObjects];        [self.tableView reloadData];        return;    }    dispatch_async(dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{        //获取狗狗列表        HttpRequest *request = [[HttpRequest alloc] init];        NSString *url = [HOMEDOGINFO_URL stringByAppendingString:[manger getToken]];        [request setStrUrl:url];        [request setCompletionBlockWithType:HttpTypeGet success:^(HttpResponse *response) {            dispatch_async(dispatch_get_main_queue(), ^{                NSArray *arr = response.responseData;                if ([arr isKindOfClass:[NSArray class]]) {                    [self.dogEpumentInfoArr removeAllObjects];                    for (int i=0; i<arr.count; i++) {                        NSDictionary *dic = arr[i];                                                HomeDogInfoModel *info = [[HomeDogInfoModel alloc] initWithDictionary:dic error:nil];                         if ((info.device != nil)||(info.device.length > 5)){                             [self getlocationDetailName:info andIndex:i];                            [self.dogEpumentInfoArr addObject:info];                         }                    }                }                _netState = YES;                [self.tableView reloadData];            });        } failure:^(HttpResponse *response) {            if (self.dogEpumentInfoArr.count == 0) {                if (response.stateCode == 0) {                    _netState = NO;                    [self.tableView reloadData];                }            }        }];    });    }
#pragma mark -- 根据经纬度获取当前地理位置- (void) getlocationDetailName:(HomeDogInfoModel *)model andIndex:(NSInteger)index {    //    dispatch_async(dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{        CLGeocoder *geocoder = [[CLGeocoder alloc] init];        CLLocation *location=[[CLLocation alloc]initWithLatitude:model.latitude longitude:model.longitude];        [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {            if (error||placemarks.count==0) {            }else//编码成功            {                for (CLPlacemark *placeMark in placemarks)                {                                        NSDictionary *addressDic=placeMark.addressDictionary;                    model.location = [[addressDic objectForKey:@"Name"] stringByAppendingString:@"附近"];                     [self refishTablecell:index + 1];                                    }            }        }];    });}