Iphone – How to know when UIView becomes completely hidden

iphoneuiresponderuiviewuiviewcontroller

I am switching between two views by toggling hidden attributes. How would I know when one view gets hidden and/or visible?

Tried setting break points into viewDidLoad, viewDidUnload, viewWillAppear, viewWillDisappear, viewDidDisappear, becomeFirstResponder and resignFirstResponder. Nothing. None of those are called, when I set hidden = YES/NO.

if (self.aController)
    self.aController.view.hidden = YES;
if (self.bController)
    self.bController.view.hidden = NO;
[self.bController viewWillAppear:YES];

I call viewWillAppear by myself, since that view is… subview of subview of view under UITabBarItem. Apple docs told that the setup is unnatural and some automatic notifications have to be done manually. Is this the same problem with not getting becomeFirstResponder and resignFirstResponder which are supposed to be related to hidden status?

Best Answer

One option is to use Key-Value Observation to observe the hidden property of either views. When the change is triggered, you'll get a message about the change.