当我滚动我的UITableView时,细胞变得混乱.我究竟做错了什么?
这是我的方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
[cell insertSubview:[itemArray objectAtIndex:indexPath.row] atIndex:indexPath.row];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
更新
它现在通过使用cell.contentView工作,但现在当我选择一个项目时,所选项目将覆盖不同单元格的内容...