[MonoTouch] MonoTouch.Dialog Pull-to-Refresh

2012-02-26 Thread Brett Spurrier
Hi all,

I have a DialogViewController which I am trying to implement the
Pull-to-Refresh functions.
However, everytime I add the line:

this.RefreshRequested += delegate {
   NSTimer.CreateScheduledTimer (1, delegate {
   this.ReloadComplete();
   } );
} ;

it crashes.

I've been trying to follow the example at:
https://github.com/migueldeicaza/MonoTouch.Dialog/blob/master/Sample/DemoRefresh.cs

which works when I run the sample project. But when I try to move the logi
to my own app, it crashes.
The Table displays just fine. It's only when I add the RefreshRequested
handler that it crashes.

Does anyone have any experience with this?

Many thanks!
Brett
___
MonoTouch mailing list
MonoTouch@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monotouch


Re: [MonoTouch] MonoTouch.Dialog Pull-to-Refresh

2012-02-26 Thread Craig Dunn
Brett,

short answer: attach the handler in the ctor.

TL;DR

the code at DialogViewController.cs line 63 is this (MonoTouch.Dialog
source is on github https://github.com/migueldeicaza/MonoTouch.Dialog/):

if (tableView != null)
throw new ArgumentException (You should set the handler before the
controller is shown);

*
*
i guess adding the handler after the tableView has been created is too late
for the MT.D core to wire it up

p.s. i'm not sure you need the NSTimer - i think in Miguel's sample that's
just to create a delay to simulate network activity. in your implementation
just do work to reload your data and call ReloadComplete() when you are
finished.

p.p.s. the MWC app sample implements pull-to-refresh in News  Twitter
screens, also on
githubhttps://github.com/xamarin/mobile-samples/blob/master/MWC/MWC.iOS/Screens/Common/News/NewsScreen.cs

HTH
cd



On Mon, Feb 27, 2012 at 12:27 PM, Brett Spurrier
brett.spurr...@gmail.comwrote:

 Hi Jason,

 this is a DialogViewController(). So I implemented a new instance of the
 DialogViewController, then put that block of code in the ViewDidLoad()
 method.

 The app just shuts down stating an exception at DialogViewController.cs
 line 63. I have no idea what that means though. MD certainly doesn't
 pronounce the exception very well if one is fired.

 Any thoughts? Is there a particular order to where I should include the
 RefreshRequested block of code?

 Cheers,
 Brett


 On Sun, Feb 26, 2012 at 8:24 PM, Jason Awbrey ja...@awbrey.net wrote:

 what context are you doing this in (ie, what is this - a class derived
 from DVC, or something else?)

 what specifically is the error when it crashes?

 On Sun, Feb 26, 2012 at 6:29 PM, Brett Spurrier brett.spurr...@gmail.com
  wrote:

 Hi all,

 I have a DialogViewController which I am trying to implement the
 Pull-to-Refresh functions.
 However, everytime I add the line:

 this.RefreshRequested += delegate {
NSTimer.CreateScheduledTimer (1, delegate {
this.ReloadComplete();
} );
 } ;

 it crashes.

 I've been trying to follow the example at:

 https://github.com/migueldeicaza/MonoTouch.Dialog/blob/master/Sample/DemoRefresh.cs

 which works when I run the sample project. But when I try to move the
 logi to my own app, it crashes.
 The Table displays just fine. It's only when I add the RefreshRequested
 handler that it crashes.

 Does anyone have any experience with this?

 Many thanks!
 Brett

 ___
 MonoTouch mailing list
 MonoTouch@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/monotouch




 ___
 MonoTouch mailing list
 MonoTouch@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/monotouch


___
MonoTouch mailing list
MonoTouch@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monotouch