0
我在关注本教程:http://www.appcoda.com/ios-programming-tutorial-create-a-simple-table-view-app/,其中显示了如何创建UITableView
并以编程方式填充它。一切顺利,有效。以编程方式填充的UITableView无法填充屏幕
现在,我试图让表格填满屏幕:不管设备或方向如何。我这样做:(?我想这是某个遥远的地方,由于与约束的问题)
但现在的表视图根本不会出现在我的屏幕。
真的没有太多的代码给我展示。我从字面上将UITableView
放入界面构建器中,然后按照教程将代理设置到我的视图控制器。方法是
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
return cell;
}
其中tableData
是一个16字符串的数组。