简单的问题,我根本不知道如何解决这个问题,我知道有很多类似的问题,对不起!UITableView内容重置时滚动
相当简单,我给我的UITableViewCell
添加UITextField
。用户可以输入它,然后滚动出来并返回到视图中,内容将被重置回默认状态。
这是关于重新使用旧电池与dequeueReusableCellWithIdentifier
对吗?我只是不明白如何解决它!
这里是我的代码:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
//Stop repeating cell contents
else for (UIView *view in cell.contentView.subviews) [view removeFromSuperview];
//Add cell subviews here...
}
希望能对你有所帮助,谢谢。
嗯,我曾想过这件事。只需将我的代码添加到if语句中,现在我的表就是空的。为什么会这样? –
解决了它,我使用了我在故事板中使用的单元格标识符。通过使用一个独特的,它会按预期添加子视图。谢谢。 –