UITableView
에는 2 개의 다른 고유 식별자가있는 UITableViewCell
이 있습니다.셀 재로드에서 이전 행의 UITableViewCell 내용이 계속 표시됩니다.
첫 번째 사용자 정의 UITableViewCell
을 Load
에로드 한 다음 두 번째 사용자 정의 UITableViewCell
을 Cell Select
에로드합니다.
내 문제는 내 셀을 재사용하는 방식과 관련이 있다는 것을 알고 있습니다. 그러나 사용하려고 시도했습니다
routineSearchSelectedResultCell * cell = (routineSearchSelectedResultCell*)[tableView dequeueReusableCellWithIdentifier:nil];
결과는 새로운 UITableViewCell
이 비어 있으며 속성이 채워지지 않습니다.
나는 또한 [[[cell contentView] subviews] makeObjectsPerformSelector: @selector(removeFromSuperview)];
을 시도했지만 동일한 결과를 제공합니다.
어떻게이 문제를 해결할 수 있습니까 ??
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (idp && idp.row == indexPath.row ) {
return [self tableViewRoutineSelectedResult:tableView cellForRowAtIndexPath:indexPath];
}
NSString *cellIdentifier = @"routineSearchCell";
routineSearchCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[routineSearchCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
cell.routineName.text = _myDownloadedInfo[@"routines"][indexPath.row][@"routine"][@"routineName"];
cell.routineAuthor.text = _myDownloadedInfo[@"routines"][indexPath.row][@"routine"][@"username"];
return cell;
}
- (routineSearchSelectedResultCell *)tableViewRoutineSelectedResult:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary* myRoutine = _myDownloadedInfo[@"routines"][indexPath.row][@"routine"];
[self sortOutRoutineImages:myRoutine[@"routineType"]];
NSString *cellIdentifier = @"routineSearchSelectedResultCell";
routineSearchSelectedResultCell * cell = (routineSearchSelectedResultCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[routineSearchSelectedResultCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
cell.label1.text [email protected]"test";
cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"BlackGradientSearch"]];
cell = [self iconRoutineImagesController:cell];
cell.imgInstruction.image = [UIImage imageNamed:@"InstructionSearchWhite"];
cell.imgVideos.image = [UIImage imageNamed:@"VideoSearchWhite"];
cell.routineName.text = myRoutine[@"routineName"];
[cell.download setBackgroundImage:[UIImage imageNamed:@"DownloadSearchWhite"] forState:UIControlStateNormal];
return cell;
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (idp) {
NSIndexPath* pIdp = [[NSIndexPath alloc] init];
pIdp = idp;
idp = indexPath;
[tableView beginUpdates];
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
[tableView reloadRowsAtIndexPaths:@[pIdp] withRowAnimation:UITableViewRowAnimationRight];
[tableView endUpdates];
} else {
idp = [[NSIndexPath alloc]init];
idp = indexPath;
[tableView beginUpdates];
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
[tableView endUpdates];
}
}
은 그래서 당신은'IDP를 할당 가정 메신저 .. 당신을 도움이 될 수 있습니다. 행'을 선택하고'reloadData'를 호출하면됩니까? – KDaker
방금'didSelectRowAtIndexPath' 코드를 추가했습니다 –
그래서 문제가 정확히 무엇입니까? 그림에서 셀이로드중인 것 같습니다. 다시로드하면 사라질 것으로 예상됩니까? – KDaker