简体   繁体   中英

Using NSTimer to call SetNeedsDisplay in Xamarin for iOS

I have a UIView that takes data (thats changing) from a buffer and plots it. I want the screen udpated at 10Hz. The UIView is called pane, and this is how i'm invoking it inside the ViewController:

        //create graphics to display data
        GraphPane pane = new GraphPane ();
        pane.Frame = UIScreen.MainScreen.Bounds;
        Add (pane); 

        //setup timer to update pane
        NSTimer timer = NSTimer.CreateRepeatingTimer (0.1, delegate {pane.SetNeedsDisplay ();});

This isn't working (Pane.Draw is never called), and I've not found a good example of how to do this. Any suggestions are appreciated.

        timer = NSTimer.CreateRepeatingScheduledTimer (TimeSpan.FromSeconds (0.1), delegate {
            pane.SetNeedsDisplay ();
        });

fixed my issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM