Muhammad Nabeel Arif
Muhammad Nabeel Arif

Reputation: 19310

UIView's methods when it is loaded/visible and unloaded/disappeared

I am building a custom control, in which I want to register control (subclass of UIButton) for notification when it is loaded, and unregister when UIView is unloaded.

I have searched a lot, and found numerous methods for UIViewController's life cycle but not for simple UIView.Can you provide methods when I can determine start and end of UIView

Upvotes: 1

Views: 803

Answers (1)

gabriel_101
gabriel_101

Reputation: 808

What about registering for notifications when the control is created (with initWithFrame and initWithCoder) and deregistering when the control is destructed (in dealloc). You can then check for self.window at every notification to see if the control is visible.

Upvotes: 1

Related Questions