UITable 视图不会重新加载



我有一个UITableView,它被放在一个基于视图的应用程序中。它连接得很好,因为我一开始可以给它发送数据。问题是清理桌子。我可以清除NSMutableArray,但数据仍然显示在表中。

-(void)logout {
NSLog(@"LOGOUT");
[friends removeAllObjects];
NSLog(@"%@", friends);
[tableView reloadData];
}

这里是位于索引路径的行的单元格:-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithFrame:CGRectZero];
}
// Set up the cell...
NSString *cellValue = [friends objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;

return cell;
}

创建一个专用的引用

@property(nonatomic, retain) IBOutlet UITableView *tableViewReference;

在注销方法中重新加载该引用。

最新更新