【问题标题】:UITable View doesn't reloadUITableView 不会重新加载
【发布时间】:2011-09-18 07:53:47
【问题描述】:

我有一个 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;
}

【问题讨论】:

  • 你的返回表格视图行数的方法是什么样的?
  • - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [朋友数]; }

标签: uitableview nsmutablearray reloaddata


【解决方案1】:

创建专用参考

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

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

【讨论】:

    猜你喜欢
    • 2013-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-21
    • 1970-01-01
    • 1970-01-01
    • 2011-08-26
    相关资源
    最近更新 更多