나는 많은 셀을 가지고 있는데, 셀에는 일련의 행을 표시하는 레이블이 있습니다. 테이블에서 셀을 움직이면 셀이 새로운 행에 따라 번호를 다시 매기기를 원합니다. 아래 코드를 시도한 후에 숫자는 모두 꺼져 있습니다. 어떻게 해결할 수 있을까요?이동 한 후 셀 번호를 다시 매기기
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{
for (int section = 0; section < [tableView numberOfSections]; section++) {
for (int row = 0; row < [tableView numberOfRowsInSection:section]; row++) {
NSIndexPath* cellPath = [NSIndexPath indexPathForRow:row inSection:section];
CustomCell* cell = (CustomCell *)[tableView cellForRowAtIndexPath:cellPath];
NSString *rowString1 = [NSString stringWithFormat:@"%d.", row + 1];
cell.periodLabel.text = rowString1;
}
}
}