插入的無數據的viewit
- (UIView *)noDataViewtable
{List
if (_noDataView == nil) {方法
_noDataView = [[UIView alloc] initWithFrame:CGRectMake(15, 15, self.tableView.width-30, self.tableView.height-130)];im
_noDataView.backgroundColor = [UIColor whiteColor];數據
[self.tableView insertSubview:_noDataView atIndex:0];img
UIImageView *_imgView = [[UIImageView alloc] initWithFrame:CGRectMake((_noDataView.width-100)/2.0f, (_noDataView.height-100)/2.0f-30, 100, 100)];tab
_imgView.image = [UIImage imageNamed:@"nodata_history"];view
[_noDataView addSubview:_imgView];vi
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;
}