您好,欢迎来到知库网。
搜索
您的当前位置:首页点击UIStatusBar UIScrollView/UITab

点击UIStatusBar UIScrollView/UITab

来源:知库网

点击UIStatusBar UIScrollView/UITableView等不回到顶部问题解决方法

UIScrollView 有一个属性大家先看下:

// 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.

在一个视图控制器中,如果只有一个scrollView ,并且这个属性(scrollsToTop)设置为yes时 才会响应这个事件。

如果有两个或者两个以上scrollView时,需要把其中一个sceollView.scrollsToTop = YES;其他的scrollview.scrollsToTop = NO 这样才会响应这个事件。
原理很简单,如果有2个或以上scrollview,系统根本不知道你需要哪个滚动到最上面。
比如一个UIViewController中有两个UIScrollView视图,分别为 scrollview1和scrollview2,

        scrollview1.scrollsToTop = YES;
        scrollview2.scrollsToTop = NO;

这样点击状态栏时,scrollView1会回到顶部。

Copyright © 2019- zicool.com 版权所有 湘ICP备2023022495号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务