Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
448 views
in Technique[技术] by (71.8m points)

ios - how to check when UITableView is done scrolling

Is there a way to check if my tableview just finished scrolling? table.isDragging and table.isDecelerating are the only two methods that I can find. I am not sure how I can either anticipate or get notified when the tableview finishes scrolling.

Can I somehow use timers to check every second if the tableView is scrolling or not?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You would implement UIScrollViewDelegate protocol method as follows:

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    if (!decelerate) {
        [self scrollingFinish];
    }
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    [self scrollingFinish];
}

- (void)scrollingFinish {
    //enter code here
}

Swift version

public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
    if decelerate {
        scrollingFinished()
    }
}

public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
    scrollingFinished()
}

func scrollingFinished() {
    print("scrolling finished...")
}

For the above delegate method The scroll view sends this message when the user’s finger touches up after dragging content. The decelerating property of UIScrollView controls deceleration. When the view decelerated to stop, the parameter decelerate will be NO.

Second one used for scrolling slowly, even scrolling stop when your finger touch up, as Apple Documents said, when the scrolling movement comes to a halt.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...