use of setNeedsDisplay

JFS picture JFS · Aug 6, 2013 · Viewed 8k times · Source

I'm confused with the different use of setNeedsDisplay to update an UIView? I do get an error message ("No visible @interface for viewcontroller declares the selector setNeedsDisplay") when I try to use:

[self.view setNeedsDisplay:YES];

I found out that I have to ignore the argument to make it work for UIViews:

[self.view setNeedsDisplay]

Why is the argument for the UIView update not needed here? (A lot of answers for how to use setNeedsDisplay suggests the first approach)

Thanks

Answer

Michael Dautermann picture Michael Dautermann · Aug 6, 2013

case sensitivity matters, b.t.w.

change that to:

[self.view setNeedsDisplay];

And as you've discovered, you call "setNeedsDisplay" on the UIView object, not the UIViewController (which is the "No visible @interface for viewcontroller declares the selector 'setNeedsDisplay'" error you were seeing).

The place where "setNeedsDisplay:" takes a YES or NO parameter is on the Macintosh side, in NSView.