我目前有一个uitableview的地方。隐藏空UItableView单元格/行
数据是从sqlite文件中获取的。
sqlite的文件的每一列将代表名单:标签,图像等
的代码我使用让行是
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
AppDelegate* appdelegate = (AppDelegate*) [[UIApplication sharedApplication]delegate];
return [appdelegate.arrayDatabase count];
}
填充细胞的代码
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"simpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == Nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:simpleTableIdentifier];
}
AppDelegate * appdelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];
ShowsList *sShows = [appdelegate.arrayDatabase objectAtIndex:indexPath.row];
cell.textLabel.text = [sShows strName ];
}
我遇到的问题:
我想使用标签列填充ViewController1.tableview的单元格文本,但它返回空行并在视图中显示空行/单元格。
但我想通过计数空单元格并将计数应用于numberOfRowsInSection:方法或通过简单地隐藏空单元格来隐藏行。
Hide empty cells in UITableView & How to hide a section in UITableView?看起来像类似的东西,但没有解决我的问题。
可能有人请点我沿着正确的方向或提供答案:)
非常感谢
托马斯
你是否将tableView的委托设置为自己? –
appdelegate.arrayDatabase中有什么?你有东西吗? –
你是否在@“”或者你的模型/数组中获得了空字符串? –