Xamarin iOS, UITableView, Scroll to load more

2020-03-24 04:12发布

问题:

Can you please share code snippets or direct me to the xamarin docs, how to implement UITableView, scroll to load more functionality.

How to detect if the tableview has scrolled to the bottom?

Thanks in advance!

回答1:

inside the TableViewSource class override this method

public override void WillDisplay (UITableView tableView, UITableViewCell cell, NSIndexPath     indexPath)
    {

        if (indexPath.Row == tableItems.Count - 1) {
            //Reload your data here
        }
    }


回答2:

constructor TableViewSource class

isScrolling = false;

inside the TableViewSource class override this method

public override void Scrolled (UIScrollView scrollView)
    {
        // load more bottom
        float height = scrollView.Frame.Size.Height;
        float distanceFromBottom = scrollView.ContentSize.Height - scrollView.ContentOffset.Y;
        if(distanceFromBottom < height && isScrolling == false) 
        {
            // reload data here
        }
    }