Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What similar functionality method (viewWillAppear) exists on UIView?

viewWillAppear is called on UIViewController when a view is about to be shown on screen. Is it possible to get similar callback on UIView?

like image 234
Centurion Avatar asked May 02 '12 12:05

Centurion


People also ask

What is IOS viewWillAppear?

Notifies the view controller that its view is about to be added to a view hierarchy.

Is viewDidAppear called everytime?

viewDidAppear is called once you see the loaded view on screen. It is called after view appeared. ViewDidAppear is called everytime when you see the view after it is loaded.

Will appear or did appear?

Show activity on this post. Difference between "will" and "did"... As the name suggests the viewWillAppear is called before the view is about to appear and viewDidAppear is called when view did appear.


2 Answers

How about the following from the UIView reference

willMoveToSuperview:, didMoveToSuperview - Implement these methods as needed to track the movement of the current view in your view hierarchy.

this will at least tell you when it is added to a view hierarchy but there is no guarantee that the view hierarchy is presented/viewable.

like image 56
Paul.s Avatar answered Sep 17 '22 13:09

Paul.s


No, but you can forward that notification to the desired view from your view controller.

like image 41
MacTeo Avatar answered Sep 18 '22 13:09

MacTeo