Azin Nilchi
Azin Nilchi

Reputation: 899

how to load more data on the scroll bottom with off bounce on scrolling?

I have a table view which I get the data from server. with the code bellow, I detect the bottom of scrollview and with loadMore() I get my data from server again!

func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {

    // UITableView only moves in one direction, y axis
    let currentOffset = scrollView.contentOffset.y
    let maximumOffset = scrollView.contentSize.height - scrollView.frame.size.height

    // Change 10.0 to adjust the distance from bottom
    if maximumOffset - currentOffset <= 200.0 {
        self.loadMore()
    }
}

my problem is when I uncheck the bounce on Scroll off and my datas height are less than the view, I can't load more data anymore! but when the bounce is on, its working perfectly!

how can I solve this issue?!

can I set bounce only for the top of the view?!

or is there any other way to load data, with bounce uncheck?

Upvotes: 0

Views: 383

Answers (1)

Danish Merani
Danish Merani

Reputation: 156

I guess since you have less data than the actual height of the view, it should not load the data as well.

In case the data is updated dynamically and there is a chance the more data can be populated, it must be done through pull to refresh.

Upvotes: 1

Related Questions