ios – 如果向上滚动,UITableview标题不再显示

ios – 如果向上滚动,UITableview标题不再显示,第1张

概述我有UITableview控制器,在标题中有搜索栏.当我向上滚动表格视图并且它反d时.但搜索栏隐藏了.当我向下滚动然后显示的搜索栏.任何人都可以告诉我如何再次显示搜索栏? 我尝试了以下代码,但它无法顺利运行: - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat sectionHeaderHeight = 40;/ 我有UItablevIEw控制器,在标题中有搜索栏.当我向上滚动表格视图并且它反d时.但搜索栏隐藏了.当我向下滚动然后显示的搜索栏.任何人都可以告诉我如何再次显示搜索栏?

我尝试了以下代码,但它无法顺利运行:

- (voID)scrollVIEwDIDScroll:(UIScrollVIEw *)scrollVIEw {    CGfloat sectionheaderHeight = 40;//Change as per your table header hight    if (scrollVIEw.contentOffset.y<=sectionheaderHeight&&scrollVIEw.contentOffset.y>=0) {        //scrollVIEw.contentInset = UIEdgeInsetsMake(-scrollVIEw.contentOffset.y,0);    } else if (scrollVIEw.contentOffset.y>=sectionheaderHeight) {        CGPoint newOffset = CGPointMake(0,-[self.tableVIEw  contentInset].top);        [self.tableVIEw setContentOffset:newOffset animated:YES];    }}

这是滚动前查看的屏幕截图:

这是错误的观点,滚动后:

解决方法 如何禁用动画关闭并放置这样的自定义动画:

还可以确保使用MAcro具有相同的sectionheader高度.我仍然怀疑你的评论是35或25.

- (voID)scrollVIEwDIDScroll:(UIScrollVIEw *)scrollVIEw {            CGfloat sectionheaderHeight = 40;//Change as per your table header hight            if (scrollVIEw.contentOffset.y<=sectionheaderHeight&&scrollVIEw.contentOffset.y>=0) {    [UIVIEw animateWithDuration: 1.0                      animations: ^{                          scrollVIEw.contentInset = UIEdgeInsetsMake(-scrollVIEw.contentOffset.y,0);                      }completion: ^(BOol finished){                      }        ];            } else if (scrollVIEw.contentOffset.y>=sectionheaderHeight) {                CGPoint newOffset = CGPointMake(0,-[self.tableVIEw  contentInset].top);[UIVIEw animateWithDuration: 1.0                  animations: ^{                      [self.tableVIEw setContentOffset:newOffset animated:NO];                  }completion: ^(BOol finished){                  }    ];            }}
总结

以上是内存溢出为你收集整理的ios – 如果向上滚动,UITableview标题不再显示全部内容,希望文章能够帮你解决ios – 如果向上滚动,UITableview标题不再显示所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1029688.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存