www.robkerr.com
www.robkerr.com

mobile development, cloud computing and building great software

Rob Kerr
Author

Addicted to coding since writing my first programs for the Commodore computers in the 1980s. Currently working as an independent contractor focused on native iOS development.

Share


Tags


Twitter


Testing whether a view is currently visible

Rob KerrRob Kerr

When manipulating iOS UI from background threads, or in response to NSNotification messages, you won't always be sure that the view your controller is working with is on-screen. How can you check?

Relatively easy. Here's a simple check from within the context of a View's ViewController:

if self.isViewLoaded() && self.view.window != nil {
    // do something
}

This is appropriate when the "something" shouldn't be executed unless the view is currently visible to the user.

Rob Kerr
Author

Rob Kerr

Addicted to coding since writing my first programs for the Commodore computers in the 1980s. Currently working as an independent contractor focused on native iOS development.

Comments