我在 Storyboard上设置了一个 View Controller ,并在该 View Controller 中插入了一个 tableView。我想在 viewDidLoad 上执行 [self.tableView reloadData];
,但它说找不到属性 tableView。
这是 viewcontroller.m 文件中我的 tableView 的代码:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return @"Shared with";
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return activeUsers.count;
}
- (sharedUsersTable *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"sharedUser";
sharedUsersTable *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[sharedUsersTable alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSDictionary *key = [activeUsers objectAtIndex:indexPath.row];
NSString *name = [key objectForKey:@"shared_user_name"];
NSString *email = [key objectForKey:@"email"];
cell.textLabel.text = [NSString stringWithFormat:@"%@", name];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", email];
return cell;
}
我是否缺少一些特殊命令来在不是 TableViewCOntroller 的 View Controller 中调用 tableView?
最佳答案
您需要制作一个tableView
的IBOutlet
并在其上调用reloadData
。
关于ios - 在 viewController 中重新加载一个 tableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22669606/