小编Tuo*_*nen的帖子

iPhone UITableView与自定义单元格断断续续.如何让它顺利滚动?

我正在使用UITableView来显示使用Interface Builder创建的自定义单元格.表格滚动不是很平滑(它"断断续续")让我相信细胞没有被重复使用.这段代码有问题吗?

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

static NSString *CellIdentifier = @"TwitterCell";
TwitterCell *cell = (TwitterCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil){
    //new cell
    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"TwitterCell" 
                                                   owner:nil options:nil];

    for(id currentObject in topLevelObjects)
    {
        if([currentObject isKindOfClass:[TwitterCell class]])
        {
            cell = (TwitterCell *)currentObject;
            break;
        }
    }

}

if([self.tweets count] > 0) {
    cell.lblUser.text = [[self.tweets objectAtIndex:[indexPath row]] username];
    cell.lblTime.text = [[self.tweets objectAtIndex:[indexPath row]] time];
    [cell.txtText setText:[[self.tweets objectAtIndex:[indexPath row]] text]];
    [[cell imgImage] setImage:[[self.tweets objectAtIndex:[indexPath row]] image]];
} …
Run Code Online (Sandbox Code Playgroud)

iphone interface builder uitableview

2
推荐指数
1
解决办法
2601
查看次数

标签 统计

builder ×1

interface ×1

iphone ×1

uitableview ×1