UIApplication has a method keyWindow
, however if an alert view is showing then this returns the window of the alert view and not the main window of the application.
How can I get the app's main window?
The Main window is the main way to access other windows, load and save files, control trajectory playback, change various global program settings, access help, and to quit the program. Many of these actions can also be performed with the menu shortcut keys described in Table 5.3.
If you look at App. xaml class of your WPF application, you will see the following XAML code. Here the StartupUri sets the startup Window of an application. If you want to change the Startup window to some other window, just change this value.
In WPF we have a couple of options by using the Show() and ShowDialog() methods. Well, if you want to close the opened window when a new window gets open then you can use the Show() method: Window1 win1 = new Window1(); win1. Show(); win1.
The UIApplicationDelegate
usually has a reference to the "main window":
[[[UIApplication sharedApplication] delegate] window];
Furthermore, UIApplication
has an array of windows [[UIApplication sharedApplication] windows]
.
See the UIApplication Class Reference.
I'm not 100% sure this works in every case but this should work:
UIWindow *mainWindow = [UIApplication sharedApplication].windows[0];
The windows are ordered back to front so the main window should always be at index 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With