Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is -[UIView drawRect:] Method Invoked?

Is it invoked just before the main view is going to be shown

Can we call it whenever we want?

like image 501
wolverine Avatar asked Feb 24 '10 12:02

wolverine


1 Answers

It's called whenever the view or part of the view needs to be drawn or redrawn.

It's called when you first display the view. It's called when you alter the view. In the life cycle of a view, it may be called hundreds or even thousands of times. For example, in a text view, it is called every time a new text character is entered.

Any change in the program state that the view must reflect visually should trigger a redraw by calling setNeedsDisplay. This happens automatically in most cases but you may need to trigger it yourself if you do something non-standard.

like image 69
TechZen Avatar answered Oct 06 '22 03:10

TechZen