iOS开发之给tableview设置占位图
作者:
Ego_1973 | 来源:发表于
2017-07-28 09:49 被阅读0次 写在前面的话:
当tableview上没有数据时我们想给一张图片的话可使用以下代码
调用
dispatch_async(dispatch_get_main_queue(), ^{
[self tableReloadCtrl:self.tableview ifNeedFoot:self.classArr.count?YES:NO];
});
方法
-(void)tableReloadCtrl:(UITableView *)tableView ifNeedFoot:(BOOL)ifNeed {
[tableView reloadData];
if (!ifNeed) {
tableView.tableFooterView = [self getTableFootView:tableView.bounds str:@"nodata"];
}else{
tableView.tableFooterView = [UIView new];
}
}
-(UIImageView *)getTableFootView:(CGRect)rect str:(NSString *)str {
UIImageView * imageView = [[UIImageView alloc]initWithFrame:rect];
imageView.image = [UIImage imageNamed:str];
imageView.contentMode = UIViewContentModeCenter;
return imageView;
}
本文标题:iOS开发之给tableview设置占位图
本文链接:https://www.haomeiwen.com/subject/jedxlxtx.html
网友评论