插入的无数据的view
- (UIView *)noDataView
{
if (_noDataView == nil) {
_noDataView = [[UIView alloc] initWithFrame:CGRectMake(15, 15, self.tableView.width-30, self.tableView.height-130)];
_noDataView.backgroundColor = [UIColor whiteColor];
[self.tableView insertSubview:_noDataView atIndex:0];
UIImageView *_imgView = [[UIImageView alloc] initWithFrame:CGRectMake((_noDataView.width-100)/2.0f, (_noDataView.height-100)/2.0f-30, 100, 100)];
_imgView.image = [UIImage imageNamed:@"nodata_history"];
[_noDataView addSubview:_imgView];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, _imgView.bottom + 60, _noDataView.width, 20)];
label.text = @"暂无数据!";
label.textAlignment = NSTextAlignmentCenter;
label.font = Demon_13_Font;
label.textColor = CS_Color_DeepGray;
[_noDataView addSubview:label];
_noDataView.hidden = YES;
}
return _noDataView;
}
在得到数据的时候,判断view是否隐藏
[self showNoDataView];
是否隐藏的方法实现:
#pragma mark 显示无数据
- (void)showNoDataView
{
//判断数据条数是否为0,为0则提示无数据
self.noDataView.hidden = (self.historyListArray.count == 0)?NO:YES;
}