我已经添加了一个UITableView‘表单’视图控制器通过故事板。我已经将这个UITableView连接到了头文件中的IBOutlet。我还将control+click连接到UITableView到视图控制器的dataSource和委托出口(以前是文件所有者的预故事板)。
委托方法numberOfSectionsInTableView、numberOfRowsInSection和heightForRowAtIndexPath都被调用,但这些方法中的UITableView实例为零。而且,从来没有调用过cellForRowAtIndexPath。当然,没有表被填充/显示。
这是我第一次尝试通过童话板UITableView。有了XIB,我就会把插座连接到File的所有者,一切都很好。会有什么问题吗?
代码:
头文件
@interface LoginPopupViewController : UIViewController <UITextFieldDelegate, UITableViewDataSource, UITableViewDelegate> {
IBOutlet UITableView *loginTable;
}
委托实现
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 44.0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
发布于 2013-07-10 09:33:25
看起来,通过调整原型UITableView的高度,它使代码认为它太小,无法添加单元格,尽管它很容易符合所需的两个原型单元格。我添加了一个默认高度的新UITableView,一切都正常工作。我想你不能调整UITableViews的大小。
您绝对可以调整表视图的大小。简而言之,您需要修复struts & springs (或者如果您使用自动布局的话)。
为了详细说明,我相当肯定这是以下(易于验证)条件的组合:
当以上所有内容都为真时,表视图将被调整为零高度,以保留顶部和底部的边距。简单地调整您的支柱&弹簧(或约束),以保持高度将解决它。例如,尝试关闭灵活的高度。
https://stackoverflow.com/questions/17559474
复制相似问题