I try to use the UIRefreshControl with swift 1.2 and works fine except the UI. It is jumping and I dont know why. Here is what I am doing:
class ViewControll
For Xamarin.iOS it's looks like this:
[Register ("MyViewController")]
partial class MyViewController
{
[Outlet]
public UITableView myTableView { get; set; }
// ...
}
public partial class MyViewController : UIViewController
{
public UIRefreshControl myRefreshControl { get; set; }
public override void ViewDidLoad()
{
base.ViewDidLoad();
// ...
this.myRefreshControl = new UIRefreshControl();
this.myRefreshControl.AttributedTitle = new NSAttributedString("Load News from server...");
this.myRefreshControl.AddTarget(this, new ObjCRuntime.Selector("RefreshSource"), UIControlEvent.ValueChanged);
#region Fix the Jump problem
UITableViewController tableViewController = new UITableViewController();
tableViewController.TableView = this.myTableView;
tableViewController.RefreshControl = this.myRefreshControl;
#endregion
#region Fix the unwanted first showing
this.myRefreshControl.BeginRefreshing();
this.myRefreshControl.EndRefreshing();
#endregion
// ...
}
[Export("RefreshSource")]
private async void RefreshSource()
{
#region Edit source data
await Task.Run(() =>
{
Thread.Sleep(3000);
});
#endregion
this.myTableView.ReloadData();
this.myRefreshControl.EndRefreshing();
}
}