【问题标题】:viewForHeaderInSection is placing header above the tableViewviewForHeaderInSection 将标题放在 tableView 上方
【发布时间】:2023-03-24 04:35:01
【问题描述】:

我重写了方法viewForHeaderInSection,我意识到默认情况下它将它添加到UItableView之上,我想将它发送到tableView的后面。有什么想法吗?

这是我的代码:

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIImageView *imageView = [[UIImageView alloc] initWithImage:districtImage];
    imageView.frame = CGRectMake(10,10,300,100);
    NSLog(@"districtImage=%@",districtImage);
    return imageView;
}

编辑

好的,我现在让它向上滚动:

self.tableView.tableHeaderView = imageView;

我现在的问题是标题太大了如何减少它

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{}

似乎没有生效。

【问题讨论】:

    标签: ios objective-c uitableview


    【解决方案1】:

    随便用

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

    与应该工作的相同身体

    【讨论】:

    • @WarehouseMuzik 因为 HEADER 的视图位于该部分的顶部,但 FOOTER 的视图位于该部分的末尾。这不是你的问题吗?
    • 不,我已经有一个页脚,所以它没有帮助,我现在可以使用它但是页眉和 tableView 之间有一个间隙
    • 对不起,我误解了你的问题
    • fab 你知道为什么会有差距
    • 不,抱歉,图片视图或地区图片的尺寸有误?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多