【发布时间】:2014-03-26 18:12:10
【问题描述】:
我在我的故事板上设置了一个视图控制器,并且我在这个视图控制器中插入了一个 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 的视图控制器中调用 tableView?
【问题讨论】:
-
你设置了delegate和dataSource吗?
-
恐怕不行。我究竟在哪里定义这些?
标签: ios objective-c uitableview