UITableView部分详细说明滚动时绘图错误

pra*_*kta 1 iphone scroll uitableview

我有一个UITableView,我是showng数据indexPath.section,但是,当我快速滚动我的表视图时,它的数据保持重叠.如何解决这个问题?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";


    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        }
    switch(indexPath.section)
    {
    // case 0 to 10;
    //values change if I scroll my table 
}
Run Code Online (Sandbox Code Playgroud)

}

inc*_*eMe 6

我认为你在cellForRowAtIndex委托方法中分配了一些标签.这就是你遇到这个问题的原因.您可以通过两种方式解决此问题:

  • 在委托方法之外分配标签.设置标签的标签,并通过引用标签在cellForRowAtIndex中使用它.

  • 使用自定义单元格视图控制