tableview 没有数据显示的时候,插入无数据的view

插入的无数据的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;

}

相关文章
相关标签/搜索