我对我的UITableViewCell有个大问题。我使用故事板,我有一个自定义单元格到我的UITableVIew。我一个标识符添加到这一点,我的类代码是:如何正确使用Objective C中的单元格?
static NSString *celldentifier = @"myCellId";
CustomCell *myCell = [tableView dequeueReusableCellWithIdentifier:celldentifier];
if (celldentifier == nil) {
celldentifier = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:celldentifier];
}
...
编辑:
...
myCell.myButton.hidden = YES;
...
当我加载其他信息在细胞,我需要隐藏按钮,我做了重装表:
[self.myTable reloadData];
而在我viewController我重新加载这个tableView显示或隐藏我的单元格中的一些组件像一个UIButton。但是当我滚动时,这个按钮加了消失..
我的代码有什么问题?我怎么能解决这个问题?
显示完整的代码。您需要跟踪何时要隐藏/显示单元格中的组件。 –
该问题的实际原因是在三点之下。但你应该使用这种语法'CustomCell * myCell =(CustomCell *)[tableView dequeueReusableCellWithIdentifier:celldentifier forIndexPath:indexPath];'并删除'celldentifier'检查,它永远不会是'nil'。 – vadian
而你所拥有的代码并不合理。 'celldentifier = [[CustomCell alloc]'? –