Xamarin.IOS Adding UIRefreshControl to a table view

From WikiOD

Addind a simple UIRefreshControl to a UIScrollView[edit | edit source]

We assume a fully working UIScrollview named _scrollView;

Note that UITableView, UICollectionView are also scrollviews, hence the following examples would work on those UI elements.

First, creation & allocation

UIRefreshControl refreshControl = new UIRefreshControl();

Second, connecting the refresh event to a method. There are different ways to do that.

Style 1:[edit | edit source]

refreshControl.ValueChanged += (object sender, EventArgs e) => MyMethodCall();

Style 2:[edit | edit source]

refreshControl.ValueChanged += (object sender, EventArgs e) =>
{
    //Write code here
};

Style 3:[edit | edit source]

refreshControl.ValueChanged += HandleRefreshValueChanged;

void HandleRefreshValueChanged(object sender, EventArgs e)
{
    //Write code here
}

Third and last, adding the refresh control itself to our scrollview.

_scrollView.AddSubview(refreshControl);

Credit:Stack_Overflow_Documentation