Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh UIView for drawRect?

Tags:

iphone

Is there a way to refresh a UIView which will subsequently call drawRect?

EDIT:

I am doing [view setNeedsDisplay] however it doesn't appear to be working! Or at least my NSLog in drawRect isn't displaying.

EDIT2:

Please see comments of selected answer for the gory details! Number one tip: Make sure it's property linked!

like image 535
confused Avatar asked Dec 06 '10 01:12

confused


1 Answers

Yes! Just call

[self.view setNeedsDisplay];

from your view controller, or [self setNeedsDisplay] directly from UIView, if you're using a subclass.

EDIT: make sure you're calling this on the correct view. The code above will call the view property of the view controller you're calling it from; this isn't necessarily correct, though it depends on your needs.

Also, make sure that the outlet is connected in Interface Builder, if you're creating this view in a nib file.

like image 167
Sam Ritchie Avatar answered Sep 28 '22 06:09

Sam Ritchie