0
사용자 위치에서 건물까지의 거리 및 머리글을 표시하는 응용 프로그램을 작성합니다. 모든 것이 잘 작동하고 마지막 셀을 완벽하게 업데이트합니다. 거리 및 표제 이미지의 변경 사항을 표시합니다. 그러나 초기 cellForRowAtIndexPath가 생성 된 후 처음 15 개의 셀은 업데이트되지 않습니다. 이 업데이트는 tableView를 다시로드하는 NSTimer에서 1 초마다 호출됩니다. 태그를 사용하고 태그없이 실행 해 보았습니다. 아래는 제 코드입니다. 어떤 도움을 주셔서 감사합니다.UITableView는 마지막 셀만 업데이트합니다. 그것은 다른 15에 대한 모든 정보를 표시하지만 NSTimer 통화의 16 번째 셀만 업데이트합니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
static int locationTags[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
CNULocation * curLocation = [self.locationArray objectAtIndex:[indexPath row]];
//NSLog(@"@@@@@ LOCATION IS : %@", curLocation.name);
coord.latitude = curLocation.location.latitude;
coord.longitude = curLocation.location.longitude;
cell.textLabel.text = [curLocation name];
cell.imageView.image = [curLocation icon];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
dist = [[UILabel alloc] initWithFrame:CGRectMake(180,10,180,24)];
imgView = [[UIImageView alloc] initWithFrame:CGRectMake(290,10,24,24)];
} else {
dist = [[UILabel alloc] initWithFrame:CGRectMake(440,10,180,24)];
imgView = [[UIImageView alloc] initWithFrame:CGRectMake(640,10,24,24)];
}
[imgView setImage:[UIImage imageNamed:@"193-location-arrow copy.png"]];
atloc = false;
GeoAngle = [self setLatLonForDistanceAndAngle:userLoc];
imgView.transform=CGAffineTransformMakeRotation((direction* M_PI/180)+ GeoAngle);
dist.opaque = false;
if(boolyard && !atloc){
dist.text = [[NSString alloc] initWithFormat:@"%.02f yards",distance];
//NSLog(@"@@@@@@@Distance in [email protected]@@@@@@: %f", distance);
}else if(!boolyard && !atloc) {
dist.text = [[NSString alloc] initWithFormat:@"%.02f feet",distance];
//NSLog(@"@@@@@@@Distance in [email protected]@@@@@@: %f", distance);
}else if(atloc){
dist.text = @"You are here!";
[imgView setImage:nil];
}
dist.backgroundColor = [UIColor clearColor];
dist.textAlignment = UITextAlignmentRight;
if (tags > 15) {
tags = 0;
}
int ViewTags = locationTags[tags];
cell.tag = ViewTags;
tags++;
//NSLog(@"Tags: %i",tags);
dist.tag= ViewTags;
imgView.tag = ViewTags;
[cell.contentView addSubview:imgView];
[cell.contentView addSubview:dist];
}else {
if (tags > 15) {
tags = 0;
}
int ViewTags = locationTags[tags];
cell.tag = ViewTags;
tags++;
imgView.tag = ViewTags;
dist.tag=ViewTags;
dist.opaque = true;
imgView.opaque = true;
//[imgView setImage:[UIImage imageNamed:@"193-location-arrow copy.png"]];
GeoAngle = [self setLatLonForDistanceAndAngle:userLoc];
imgView.transform=CGAffineTransformMakeRotation((direction* M_PI/180)+ GeoAngle);
if(boolyard && !atloc){
dist.text = [[NSString alloc] initWithFormat:@"%.02f yards",distance];
//NSLog(@"@@@@@@@Distance in [email protected]@@@@@@: %f", distance);
}else if(!boolyard && !atloc) {
dist.text = [[NSString alloc] initWithFormat:@"%.02f feet",distance];
//NSLog(@"@@@@@@@Distance in [email protected]@@@@@@: %f", distance);
}else if(atloc){
dist.text = @"You are here!";
[imgView setImage:nil];
}
}
//boolyard = true;
//atloc = false;
return cell;
}
감사합니다. – rugers285