Summary of scrollsToTop problem in IOS

scrollsToTop summary:

UIScrollView is a class used to display scrolling. He has subclasses such as UITableView and UITextView.

scrollsToTop is a property of UIScrollView, which is mainly used to scroll back to the top when the control with scrollsToTop == YES is clicked on the status bar of the device.

For each default instance of UIScrollView, its scrollsToTop property defaults to YES, so to implement a UIScrollView instance to click the device status bar to return to the top, you need to close the scrollsToTop property of other UIScrollView instances to NO. It's easy to understand: if multiple scrollViews respond to the event of returning to the top, the system will not know which scrollView to return to the top, so it will not do anything. . .

Take a chestnut:

Only when a UIViewController controller has a scrollview and set this property to yes,

Other scrollview.scrollsToTop = NO will respond to this event. The principle is very simple. If there are 3 scrollviews, the system will not know which one you need to scroll to the top.
        For example, there are three UIView views in a UIViewController, namely   _pushList,   _photoList,   _starList, and each view has a UITableView, the settings are as follows:
    
        _pushList.table.scrollsToTop = YES;

        _photoList.table.scrollsToTop = NO;

        _starList.table.scrollsToTop = NO;

Understand? It should be noted that UIWebView contains subview UIWebViewScrollView, which is also a subclass of UIScrollView. I didn’t realize this at the beginning, which made it impossible to click the status bar to return to the top. Set the scrollsToTop of UIWebViewScrollView to NO, which is normal.

Guess you like

Origin blog.csdn.net/enuola/article/details/32331933