Forked from Azuritul/Check UIViewController Visibility
Last active
August 29, 2015 14:10
-
-
Save saltwat5r/cc50ba2e5d8c66459049 to your computer and use it in GitHub Desktop.
This file contains hidden or 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