如何在TableView下面添加View?

时间:2015-07-30 09:48:38

标签: ios objective-c uitableview uiimageview

如何在View下面添加ImageViewUITableView)?

可以使用UITableView

滚动视图

因为我的TableItem可以展开

1 个答案:

答案 0 :(得分:1)

您需要实现UITableViewDelegate方法

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

并为表格的相应部分返回所需的视图(例如,带有您在页脚中的文字的UILabel)。

有点像下面。

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 30.0f;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *sampleView = [[UIView alloc] init];
    sampleView.frame = CGRectMake(x, y, width, height);
    sampleView.backgroundColor = [UIColor blackColor];
    return sampleView;
}

并包含UITableViewDelegate协议。

@interface TestViewController : UIViewController <UITableViewDelegate>