What is the correct way to reload UIView?

While I was working with iOS applications all of a sudden, I had a question. What if I want to reload the whole view? What happens if I call viewDidLoad ? Is this the right way to do this? I ask only for my knowledge.

+4
source share
3 answers

If the view is the main view of some controller, you can reload it by setting the view property for nil controllers - it will be loaded again the next time someone uses the view property. Calling -viewDidLoad will not work, it's just a callback method called by some UIViewController code when the view is complete.

+3
source

You can use the following simple code to reload the view.

 [YOUR_VIEW setNeedsDisplay]; 
+2
source

If you want to reload the entire view, you can use the reloadInputViews method or write code in viewWillAppear , so every time you create a new object of your viewController, the code in viewWillAppear will resemble itself.

+1
source

Source: https://habr.com/ru/post/1436067/


All Articles