2016-01-04 309 views
0

我在关注本教程:http://www.appcoda.com/ios-programming-tutorial-create-a-simple-table-view-app/,其中显示了如何创建UITableView并以编程方式填充它。一切顺利,有效。以编程方式填充的UITableView无法填充屏幕

现在,我试图让表格填满屏幕:不管设备或方向如何。我这样做:(?我想这是某个遥远的地方,由于与约束的问题)

enter image description here

但现在的表视图根本不会出现在我的屏幕。

真的没有太多的代码给我展示。我从字面上将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字符串的数组。

回答

1

尝试删除所有约束,然后选择tableView并再次添加并按添加4个约束。当然,你没有一些含糊之处。

enter image description here