Created
August 31, 2011 08:54
-
-
Save Azuritul/1183108 to your computer and use it in GitHub Desktop.
Check if a view controller is visible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Check http://stackoverflow.com/questions/2777438/how-to-tell-if-uiviewcontrollers-view-is-visible | |
* to see the discussions. | |
* If the container is a UINavigationController, | |
* we can use the visibleViewController property | |
* to check the visibility. | |
*/ | |
navigationController visibleViewController == self | |
/* Or, we can add a category to UIViewController | |
* to check it. | |
*/ | |
@interface UIViewController (CategoryName) | |
-(BOOL) isVisible; | |
@end | |
@implementation UIViewController (CategoryName) | |
-(BOOL) isVisible { | |
return [self isViewLoaded] && self.view.window; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment