[英]Programmatically populated UITableView can't fill the screen
I am following this tutorial: http://www.appcoda.com/ios-programming-tutorial-create-a-simple-table-view-app/ which shows how to create an UITableView
and populate it programmatically. 我正在学习本教程: http : //www.appcoda.com/ios-programming-tutorial-create-a-simple-table-view-app/ ,它显示了如何创建UITableView
并以编程方式填充它。 All's good, it works. 很好,它有效。
Now, I am trying to make the table fill the screen: regardless of the device or orientation. 现在,我试图使表格填满屏幕:无论设备或方向如何。 I did this: 我这样做:
But now the table view simply does not appear in my screen (I imagine it is somewhere far away due to a problem with the constraints?). 但是现在表格视图根本没有出现在我的屏幕上(我想由于约束问题,它就在很远的地方了吗?)。
There really isn't much code for me to show. 我真的没有太多要显示的代码。 I literally just placed an UITableView
into the interface builder, and followed that tutorial to set the delegate to my view controller. 我实际上只是将UITableView
放入界面构建器中,然后按照该教程将委托设置为我的视图控制器。 The methods would be 该方法将是
- (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;
}
Where tableData
is an array with 16 strings. 其中tableData
是具有16个字符串的数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.