Iphone UITableView重新加载数据问题

Iphone UITableView重新加载数据问题,iphone,objective-c,ipad,Iphone,Objective C,Ipad,我遇到过几次这样的情况,我试图做的基本上是调用tableView reloadData,但是并不是单元格中的所有值都在更新。前5行总是不更新。。。我必须滚动到底部,然后再向上滚动才能更新它。为什么会这样 这是我的密码: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifi

我遇到过几次这样的情况,我试图做的基本上是调用
tableView reloadData
,但是并不是单元格中的所有值都在更新。前5行总是不更新。。。我必须滚动到底部,然后再向上滚动才能更新它。为什么会这样

这是我的密码:

- (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.textLabel setFont:[UIFont fontWithName:@"Arial" size:16]];
    }


    //add a button to set to accessory view
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    //I missed setting the frame yesterday!
    //[button setFrame:CGRectMake(200, 20, 20, 20)];
    [button setImage:[UIImage imageNamed:@"addsource.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(changeButton:) forControlEvents:UIControlEventTouchUpInside];
    [button setBackgroundColor:[UIColor clearColor]];
    cell.accessoryView = button;

    if ([[self.content objectAtIndex:indexPath.row] isKindOfClass:[Source class]]){
        Source * source = [self.content objectAtIndex:indexPath.row];
        if (![source.type isEqualToString:@"featured"]){
            [cell.textLabel setText:source.domain];
            NSURL* URL = [NSURL URLWithString:source.imageUrl];
            [cell.imageView setImageWithURL:URL
                           placeholderImage:[UIImage imageNamed:@"placeholder.jpg"]];
        }
    }

    return cell;    
}
这叫做每次我刷新整个数据集时:

 [self.content removeAllObjects];
        [self.content addObjectsFromArray:objects];
        [self.tableView reloadData];

我还没有深入研究您的代码,但这听起来像是一种症状,您可能会看到,当单元格被重用时,没有从以前的外观完全重置

当一个单元格退出队列时,它不会被重置,它只是从表视图中删除。因此,除非在下次分配时重置它,否则它将携带以前的配置和设置

因此,当您配置单元时,请确保在所有情况下都恢复单元的所有方面,而不仅仅是您这次恰好返回的单元的特定变体的设置


希望有帮助。

尝试调试以下行:
if(![source.type IsequalString:@“特色”]){


显然,如果源类型为“特色”,您的单元格将不会得到更新。请仔细检查内容数组中的所有值

是否尝试过调试?如果(![source.type IsequalString:@“特色”]){返回,您的单元格将不会得到更新?如果源类型为“特色”,您的单元格显然不会得到更新。请仔细检查您的内容数组中的所有值。是的,这实际上是问题。我会写它,它是一个答案,因此您可以接受它