多个scrollView时点击statusbar失效的解决办法

当viewController中只有一个scrollView时,点击statusBar,该scrollView就会滚动到顶部,但当viewController中有多个scrollView时,这个功能就失效了。

为什么呢?UIScrollView有个属性 ,叫scrollsToTop,看下官方注解:

“When the user taps the status bar, the scroll view beneath the touch which is closest to the status bar will be scrolled to top, but only if its `scrollsToTop` property is YES, its delegate does not return NO from `shouldScrollViewScrollToTop`, and it is not already at the top.

On iPhone, we execute this gesture only if there's one on-screen scroll view with `scrollsToTop` == YES. If more than one is found, none will be scrolled.”

@property (nonatomic) BOOL scrollsToTop  __TVOS_PROHIBITED; // default is YES.

可以看到,点击statusBar时如果发现有多个scrollView时就不会有滚动效果了。

解决办法很简单,把需要有滚动效果的scrollView的scrollsToTop属性设为YES,其他的设为NO,也就是说同一时间内只能让一个scrollView的scrollsToTop属性为YES。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Documentation Supported OS & SDK Versions 支持的OS & SDK版本 S...
    c5550ea746f8阅读 4,442评论 0 2
  • Markcf阅读 164评论 0 0
  • 阅 读,是 一 场头 脑 风 暴 最近火爆朋友圈的文章《没事别想不开去创业公司》,是我长期置顶、并且每篇必读的公众...
    猫妖转世阅读 370评论 0 1
  • 都说回不去的是家乡,到不了的是远方。这次回家发现家乡又有了新的变化,虽然下着雨,我还是打算去寻找一下过去的蛛丝马迹...
    盎然夕拾阅读 1,362评论 6 17
  • 我讨厌吊儿郎当的生活,更讨厌邋遢的自己。我的脾性可以大大咧咧,但着装、容貌却不可以不修边幅。我不追求生活的完...
    家庭妇男阅读 424评论 1 3