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.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...