scrollsToTop使用技巧

情景描述

在有TableView和ScrollView的界面中,点击屏幕的Status Bar即可回到顶部,这是因为ScrollView的property scrollsToTop默认为YES。

使用须知

在苹果文档中特别强调

On iPhone, the scroll-to-top gesture has no effect if there is more than one scroll view on-screen that has scrollsToTop set to YES.

潜在的问题

屏幕中有多个ScrollView或者其子类,此时点击Status Bar不能返回顶部。

例如code4app网易新闻Demo在使用过程中就出现了屏幕上包含多个ScrollView及其子类TableView的情况。

解决方法

只设置一个ScrollView的scrollsToTop为YES,其他设置为NO

    原文作者:leejan97
    原文地址: https://segmentfault.com/a/1190000002565738
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞