iOS 7,表头视图不浮动

我在我的应用程序上设置了UITableView,它在iOS 7上运行.我有一个部分,它将图像加载到自定义单元格中,它也在导航栏下滚动,这是半透明的.所以最初,内容在导航栏下方,当我们向下滚动以查看更多图像时,它会在导航栏下滚动.为此,我设置了UIEdgeInsetsMake(40,0)的初始contentInset.现在有时,我需要在我的桌子上有一个小的标题视图来指示我桌子上的图像类型.所以我使用了以下代码:
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    return 30.0;

}

-(UIView*) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

    TableSectionHeader *header=[[[NSBundle mainBundle] loadNibNamed:@"TableSectionHeader" owner:self options:nil] objectAtIndex:0];

    [header.title setText:[NSString stringWithFormat:@"Type: %@",self.imageType]];

    return head;
}

TableSectionHeader是我为此目的创建的自定义视图.理想情况下,标题必须浮动或“粘贴”在导航栏下方或表格顶部(位于导航栏下方).但在这种情况下,它只是滚出屏幕.我希望标题贴在导航栏下方.有谁知道我怎么能做到这一点?

解决方法

将表视图的样式从Grouped更改为Plain.

official documentation开始,关于Plain表视图样式:

A plain table view can have one or more sections,sections can have
one or more rows,and each section can have its own header or footer
title. (A header or footer may also have a custom view,for instance
one containing an image). When the user scrolls through a section with many rows,the header of the section floats to the top of the table view and the footer of the section floats to the bottom.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...