Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

applicationDidBecomeActive current screen

Tags:

uikit

ipad

How can I determine what controller/window is currently in the applicationDidBecomeActive? For example on the login screen (which is a LoginViewController), if the applicationDidBecomeActive fires how do I know it is the login screen from the appDelegate?

like image 878
fes Avatar asked Jun 24 '26 21:06

fes


1 Answers

The UIApplication object passed to applicationDidBecomeActive has a windows property. It is an NSArray of visible windows, ordered back to front.

Once you have the foreground window, you can get the first subview and test its type:

if ([[foregroundWindow.subviews objectAtIndex:0] class] == [LoginViewController.view class]) {
    ...
}
like image 54
highlycaffeinated Avatar answered Jun 26 '26 18:06

highlycaffeinated