0

ビューベースのアプリに配置される 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;
}
4

1 に答える 1

0

専用リファレンスを作成する

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

logout メソッドでその参照をリロードします。

于 2012-12-01T08:00:22.507 に答える