What does cell.layoutIfNeeded()
and cell.layoutSubviews()
and cell.setNeedsDisplay()
method do in general ?
What does cell.layoutifneeded and cell.layoutSubviews and cell.setneedsdisplay method do in general?
Asked
Active
Viewed 2,419 times
0

kamwysoc
- 6,709
- 2
- 34
- 48

Manisha Sharma
- 17
- 3
-
2In general, this community helps with specific programming problem, not a broad understanding. You need to read docs for that – saurabh Jul 06 '17 at 07:02
-
1Plz go through this site https://developer.apple.com/documentation/uikit/uitableviewcell – Dharma Jul 06 '17 at 07:04
-
1Please refer link https://stackoverflow.com/questions/14506968/setneedslayout-and-setneedsdisplay – Rajeev Singh Jul 06 '17 at 07:04
-
You can watch this https://www.youtube.com/watch?v=xjArhdrqAn8 to clarify all your questions. – Oleg Danu Jul 06 '17 at 11:13
1 Answers
1
- layoutSubviews
Lays out subviews. in short this method lets determine the size and position of any subviews, it also helps to get desired behaviour you want for your view if your have a subclass. Documentation here
2.layoutIfNeeded
Forces view to layout immediately,for example you have changed a constraints constant and to reflect the change you need to call layoutIfNeeded.(it can also be animated :P). Documentation here
- setNeedsDisplay
Marks the view need to be redrawn in the next drawing cycle, when you call this method, system is notified that view's content is changed and it will be redrawn in next drawing cycle. Documentation here
Please consider reading documentation for better understanding

Pratik Jamariya
- 810
- 1
- 10
- 35