当我滚动tableview时,如何与UItableViewCell一起使headerView滚动(不停留在tableview的顶部) [英] how can i make headerView scroll (not stay on the top of the tableview ) accompanying with UItableViewCell when i was scrolling tableview

查看:367
本文介绍了当我滚动tableview时,如何与UItableViewCell一起使headerView滚动(不停留在tableview的顶部)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在plainsytle tableview中,我们通过委托方法为每个部分设置headerViews

in plainsytle tableview , we set headerViews for each section by delegate method

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

因此,当我向上滚动tableview时,第一部分的headerView始终显示在tableview的顶部,然后该部分完全消失在tableview上,然后第二部分的headerView将显示在tableview的顶部.所以我的问题是如何使headerView与uitableViewCell一起滚动,就像组样式tableview一样?

so,when i scrolling up tableview , the first section's headerView is always showing on the top of tableview before the section totally disappear on the tableview , then the second section's headerView will show on the top of tableview instead . so my question is how can i make headerView scroll accompanying with uitableViewCell , just like group style tableview ?

推荐答案

子类化UITableView并覆盖此方法

subclass the UITableView and override this method

- (BOOL)allowsHeaderViewsToFloat{
    return NO;
}

与页脚相同

- (BOOL)allowsFooterViewToFloat{
    return NO;
}

但是我认为这是一个私有API……您将无法将其提交到AppStore

But I think that this is a private API ... You will not be able to submit it to the AppStore

如果您将其上传到AppStore;然后您还有另外两个选择

If you will upload it to the AppStore; Then you have two other options

  1. 添加普通单元格而不是节标题
  2. 如果只有一个节,则可以简单地使用表头而不是节头

这篇关于当我滚动tableview时,如何与UItableViewCell一起使headerView滚动(不停留在tableview的顶部)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆