您的位置:首页 > 产品设计 > UI/UE

UITableView 查询结果为空,显示无数据的方法

2016-02-02 21:32 633 查看
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
if (self.articles.count) {
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
self.tableView.backgroundView = nil;
return 1;
} else {
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

UILabel *label = [[UILabel alloc] initWithFrame:self.tableView.bounds];
label.text = @"没有搜索到相关文章\n请输入其它关键字再次搜索";
label.numberOfLines = 2;
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor lightGrayColor];

self.tableView.backgroundView = label;
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: