3

I am trying to create a custom ProgressBar with MonoTouch. I created a class which redraws a line with a timer. My issue is that when theSetNeedsDisplay is called the view doesn't redraw itself. Only when a touch is provided does the SetNeedsDisplay call the OnDraw method. What do I have to do so that the OnDraw method gets called without a touch?

alecnash
  • 1,750
  • 1
  • 18
  • 42
  • are you calling SetNeedsDisplay in the correct thread? If you call it in the timer-thread, it will not be drawn (look at the not accepted answer [here](http://stackoverflow.com/questions/1503761/what-is-the-most-robust-way-to-force-a-uiview-to-redraw)) – basti Jun 12 '12 at 14:16
  • 2
    you just saved me from a lot of time my friend. Just type as an answer that I have to call the main thread (InvokeOnMainThread) so that I can reward you. – alecnash Jun 12 '12 at 14:26
  • Just wrote an short answer :) – basti Jun 12 '12 at 14:39

1 Answers1

3

You need to make sure to call SetNeedsDisplay in the ui-thread, otherwise it will not redraw the view. Source

Community
  • 1
  • 1
basti
  • 2,649
  • 3
  • 31
  • 46