我正在加载一个包含两个标记标签的 UITableViewCell。用户将离开当前视图,包含以下代码并转到另一个视图。在那里设置了一个名称值,用户回到这个视图(下面的代码)。我将他们在另一个视图中设置的名称分配给名称标签。这行得通,但我得到一个新标签在我的其他标签之上未对齐。看来我保留了这个单元格的两个版本。不太确定。关于可能导致这种行为的任何建议?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = nil;
if(indexPath.section == 0)
{
cell = [tableView dequeueReusableCellWithIdentifier:@"CellNameIdentifier"];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"CellentName" owner:self options:nil];
cell = cellName;
//self.cellName = nil;
}
}
return cell;
}
- (void)viewDidAppear:(BOOL)animated {
UILabel *startdate = (UILabel *)[cellName viewWithTag:1];
startdate.text = aName;
[super viewDidAppear:animated];
}