Why do we override drawrect: method? How to explicitly call it?



Why do we override drawrect: method? How to explicitly call it?..

Answer / Sandeep Kaumr

Overriding the drawRect: method in a custom UIView subclass allows you to customize the view's drawing behavior. It gets called by the system when the view needs to be redrawn, such as after layout changes or when appearing on screen.nnTo explicitly call drawRect:, you can use the setNeedsDisplay or setNeedsLayout methods of UIView. These will trigger a redraw cycle, resulting in the drawRect: method being called.nnNote that ARC does not automatically manage the lifetime of objects created within the drawRect: method, so be careful to retain any such objects if they need to persist beyond the current draw cycle.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Apple iOS Interview Questions

What manual memory management ? How it work?

1 Answers  


What does use core data mean in xcode?

1 Answers  


What are sensors in iphone?

1 Answers  


Explain the difference between stack and heap memory?

1 Answers  


What is difference between delegate and datasource in ios?

1 Answers  


Multitasking support is available from which version?

1 Answers  


How do I open a csv file on my phone?

1 Answers  


How to deal with sqlite database?

1 Answers  


what are fetched properties? How do you create a fetched property?

1 Answers  


Why do you generally create a weak reference when using self in a block?

1 Answers  


What is notification in iOS?

1 Answers   TryTechnicals Pvt Ltd,


Explain interfaces?

1 Answers  


Categories