Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIView did appear?

Tags:

ios

iphone

uiview

I'm wondering, is there a way to get a delegate or something, when a particular UIView has been shown on the screen ?

like image 928
nosuic Avatar asked Feb 20 '11 23:02

nosuic


People also ask

What is a UIView?

The UIView class is a concrete class that you can instantiate and use to display a fixed background color. You can also subclass it to draw more sophisticated content.

What is view did appear in Swift?

Notifies the view controller that its view was added to a view hierarchy. iOS 2.0+ iPadOS 2.0+ Mac Catalyst 13.0+ tvOS 9.0+

What is the difference between UIView and UIViewController?

They are separate classes: UIView is a class that represents the screen of the device of everything that is visible to the viewer, while UIViewController is a class that controls an instance of UIView, and handles all of the logic and code behind that view.

How many times is viewDidLoad called?

viewDidLoad() is one of the initialization methods that is called on the initial view controller. viewDidLoad() is called before anything is shown to the user - and it is called only once.


2 Answers

Swift version. Inside your UIView class just:

override func willMove(toWindow newWindow: UIWindow?) {     super.willMove(toWindow: newWindow)      if newWindow == nil {         // UIView disappear     } else {         // UIView appear     } } 
like image 94
buxik Avatar answered Sep 20 '22 17:09

buxik


Try these:

– didAddSubview: – willRemoveSubview: – willMoveToSuperview: – didMoveToSuperview – willMoveToWindow: – didMoveToWindow - viewDidAppear: 
like image 28
Max Avatar answered Sep 20 '22 17:09

Max