Eduardo Coelho
Eduardo Coelho

Reputation: 1963

MonoTouch.Dialog support for Pull to Refresh in iOS 7

I'm using the native MonoTouch.Dialog support for Pull to Refresh feature on iOS, however since in iOS 7 view controllers can be shown in fullscreen mode (below the navigation bar and status bar) the Pull to Refresh feature stopped working properly.

I tried to play with TableView.ContentOffset and TableView.ContentInset properties in my MonoTouch.Dialog.DialogViewController subclass but I could not find any point of customization. MonoTouch.Dialog.DialogViewController uses a lot of private constants / fields / classes, which makes difficult to extend it.

Also the https://github.com/migueldeicaza/MonoTouch.Dialog looks outdated.

Is anyone successfully using Pull to Refresh feature in iOS 7 with MonotTouch.Dialog?

Upvotes: 0

Views: 2342

Answers (2)

Ben Anderson
Ben Anderson

Reputation: 7353

I had the same problem and had a different solution. I was doing the following

public MyController()
    : base(null)
{
    RefreshRequested += MyController_RefreshRequested;
    Root = new RootElement(null);
}

I was immediately calling ReloadComplete, this is bad dont do this

void MyController_RefreshRequested(object sender, EventArgs e)
{
InvokeOnMainThread(
delegate
     {
     ReloadComplete();
     }
}

You need to wait just a little before refreshing...

void MyController_RefreshRequested(object sender, EventArgs e)
{
     InvokeOnMainThread(
     delegate
     {
          Thread.Sleep(1000);
          ReloadComplete();
     }
}

btw, the original problem looks like it was fixed on github by bhomles: https://github.com/migueldeicaza/MonoTouch.Dialog/issues/190

Upvotes: 0

Eduardo Coelho
Eduardo Coelho

Reputation: 1963

Ok, I suddenly realized that my app deployment target is iOS >= 6.x (I have recently dropped support for iOS 5) so I can use the UIKits native UIRefreshControl instead, which scales will with both iOS 6 and iOS 7 ;).

Upvotes: 1

Related Questions