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 7,表头视图不浮动全部内容,希望文章能够帮你解决iOS 7,表头视图不浮动所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。