我现在在谷歌上寻找 3 个小时如何删除 tableview 并在 tableview 为空时显示图像(没有更多行)。有人知道吗?我知道这是可能的,因为我在很多应用程序上都看到了它。
我能找到的是:
// Check if table view has any cells
int sections = [self.tableView numberOfSections];
BOOL hasRows = NO;
for (int i = 0; i < sections; i++)
hasRows = ([self.tableView numberOfRowsInSection:i] > 0) ? YES : NO;
if (sections == 0 || hasRows == NO)
{
UIImage *image = [UIImage imageNamed:@"test.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
// Add image view on top of table view
[self.tableView addSubview:imageView];
// Set the background view of the table view
self.tableView.backgroundView = imageView;
}
在哪里放这个?
谢谢!