UITableViewController 기반입니다. 내 표, 두 부분으로 구성UITableViewCell 잘못된 콘텐츠 표시
(1) 어레이에서 프리스트 부 표시 객체 라벨 텍스트는 검정 및 세부 할 텍스트가
(2) 제 2 부분은 하나의 행을 갖고 사용 새로운 ViewController를 사용하여 더 많은 객체 추가하기
그러나 초기 뷰는 정확합니다. 그러나 배열에 객체를 추가하고 데이터를 다시로드하려고하면 테이블에 잘못된 셀에 대한 잘못된 내용이 표시됩니다.
아무도 내가 뭘 잘못했는지 말해 줄 수 있습니까?
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
if (section == 0) return self.addItems.count;
else return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"Add Items List";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier
forIndexPath:indexPath];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:cellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
if (indexPath.section == 0) {
Item *item = [self.addItems objectAtIndex:indexPath.row];
cell.textLabel.text = [NSString stringWithFormat:@"%08i", item.identifier.intValue];
cell.detailTextLabel.text = item.detailDescription;
}
else {
cell.textLabel.text = @"Create Item";
cell.textLabel.textColor = [tableView tintColor];
cell.detailTextLabel.text = nil;
}
return cell;
}
- (void)unwindToAddItemsViewController:(UIStoryboardSegue *)segue {
CreateItemViewController *source = [segue sourceViewController];
[self.addItems addObjectsFromArray:source.createItems];
[self.tableView reloadData];
}
이 메소드의 용도는 무엇입니까 'unwindToAddItemsViewController'입니까? –
두 셀 모두에 대해 동일한 셀을 사용할 계획이라면 셀의 모든 뷰를 원래 상태로 재설정하는 셀에 리셋 메소드가 있습니다. 셀을 다시 사용할 것입니다. – GoodSp33d