Questions tagged [uiwindow]
The UIWindow class defines objects (known as windows ) that manage and coordinate the windows an application displays on the screen.
uiwindow
651
questions
637
votes
18
answers
306k
views
How to tell if UIViewController's view is visible
I have a tab bar application, with many views. Is there a way to know if a particular UIViewController is currently visible from within the UIViewController? (looking for a property)
360
votes
30
answers
187k
views
How to resolve: 'keyWindow' was deprecated in iOS 13.0
I'm using Core Data with Cloud Kit, and have therefore to check the iCloud user status during application startup. In case of problems I want to issue a dialog to the user, and I do it using ...
241
votes
8
answers
147k
views
iPhone - Get Position of UIView within entire UIWindow
The position of a UIView can obviously be determined by view.center or view.frame etc. but this only returns the position of the UIView in relation to it's immediate superview.
I need to determine the ...
97
votes
10
answers
108k
views
Getting reference to the top-most view/window in iOS application
I'm creating a reusable framework for displaying notifications in an iOS application. I'd like the notification views to be added over the top of everything else in the application, sort of like a ...
93
votes
3
answers
16k
views
Advantages, problems, examples of adding another UIWindow to an iOS app?
Recently I've been wondering about the fact that that an iOS app only has one UIWindow.
It does not seem to be an issue to create another UIWindow and place it on screen.
My question is kind of vague,...
52
votes
1
answer
51k
views
How to use UIWindowScene.windows on iOS 15? [duplicate]
Currently, with iOS 14.6, I can call a function in my app that displays a share sheet using the following code:
func share(link: URL) {
let activityView = UIActivityViewController(activityItems: [...
48
votes
12
answers
40k
views
UIWindow not showing over content in iOS 13
I am upgrading my app to use the new UIScene patterns as defined in iOS 13, however a critical part of the app has stopped working.
I have been using a UIWindow to cover the current content on the ...
45
votes
6
answers
55k
views
how to get my UIWindow using UIApplication?
I have only one window and I tried
UIWindow* mWindow = [[UIApplication sharedApplication] keyWindow];
but this returned nil.
I also tried:
UIWindow* mWindow = (UIWindow*)[[UIApplication ...
45
votes
10
answers
84k
views
To create a new UIWindow over the main window
In my app I want to create a new UIWindow over the main UIWindow, And I wrote as following, but it don't works.
first, i create a UIWindow as the main window, and then make it key and visible, and ...
44
votes
6
answers
44k
views
Orientation in a UIView added to a UIWindow
I have a UIView which is supposed to cover the whole device (UIWindow) to support an image zoom in/out effect I'm doing using core animation where a user taps a button on a UITableViewCell and I zoom ...
43
votes
4
answers
6k
views
Why is main window of type double optional?
When accessing UIapplication's main window it is returned as a UIWindow??
let view = UIApplication.sharedApplication().delegate?.window // view:UIWindow??
Why is it returning as a double optional ...
42
votes
13
answers
30k
views
Unexpected nil window in _UIApplicationHandleEventFromQueueEvent
One of my old apps is not working with iOS8. When I start the app up, and try to tap on the screen anywhere, I get this message in my console:
unexpected nil window in ...
40
votes
4
answers
26k
views
What is the difference between UIApplication.sharedApplication.delegate.window and UIApplication.sharedApplication.keyWindow?
Can anyone help me understand the difference between the following two lines:
[UIApplication.sharedApplication.delegate.window addSubview:myView];
[UIApplication.sharedApplication.keyWindow ...
39
votes
8
answers
44k
views
Get Application's main window
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 ...
37
votes
7
answers
45k
views
How to remove a UIWindow?
I thought it was easy as [myWindow resignKeyWindow] and [self.window makeKeyAndVisible] but I guess not… Would you guys know what to do?
Thanks :)
35
votes
8
answers
47k
views
iOS - Get location of a view in a window?
I have a UIView that displays a popup after it's been clicked.
The popup needs to be added to the main UIWindow to make sure that it goes on top of everything else.
I want the position of this popup ...
35
votes
4
answers
43k
views
Convert a UIView origin point to its Window coordinate system
I want to get the origin of scrollView in the window coordinate system. For Example, presently, scollView origin is (0,51). But in window coordinate system it should be 51 + 44(navigation bar height)+...
32
votes
3
answers
8k
views
Passing touches between stacked UIWindows?
I have two windows -- a front one, and a back one. The front one is used to overlay some stuff on top of the back one. I want to be able to capture touches on some parts of the front window, but not ...
31
votes
4
answers
10k
views
subclassing UIWindow while using storyboards
I have same issue as explained in this question:
Where can I change the window my app uses from UIWindow to my own subclass "MyWindow" with storyboard?
My question is how do i implement a '...
31
votes
5
answers
19k
views
iPhone - UIWindow rotating depending on current orientation?
I am adding an additional UIWindow to my app.
My main window rotates correctly, but this additional window I have added does not rotate.
What is the best way to rotate a UIWindow according to the ...
27
votes
3
answers
41k
views
View on top of everything: UIWindow subview VS UIViewController subview
In order to make a UIView on top of all views like the behavior of UIAlertView, the best way I see is by putting it in the app window, which is by adding the view to:
[[[UIApplication ...
26
votes
1
answer
4k
views
Whats a key window in Objective-C Cocoa?
What is a key window? And what is it used for? I read its used for "key input";but could someone expand on this? An example would be appreciated.
25
votes
4
answers
15k
views
How to disable long touch in UIWebView?
I want to disable long-touch from the application. I have no control on the HTML that I am loading on my WebView.
25
votes
5
answers
14k
views
Changing the rootViewController of a UIWindow
When my app first loads, I set the rootViewController property of my UIWindow to controllerA.
Sometime during my app, I choose to change the rootViewController to controllerB.
The issue is that ...
25
votes
1
answer
6k
views
UIWindow endDisablingInterfaceAutorotationAnimated: error
I'm receiving the following error when a user is in MFMailComposerViewController and presses the Home button:
[UIWindow endDisablingInterfaceAutorotationAnimated:] called on > without matching -...
23
votes
3
answers
9k
views
Is it possible that an iOS application can have more than one window?
I have been asked this question many times in the interview searched every where didn't get any proper answer.So finally posting this question here.
22
votes
5
answers
11k
views
Making a button persistent across all view controllers
I want to have a persistent button in the bottom right corner of my app. During all view transitions, the button should remain static. I'm having trouble deciding what view to add the button to. I ...
21
votes
4
answers
23k
views
makeKeyAndVisible & makeKeyWindow - uiwindow in iphone
In every application,
there is always written as [window makeKeyAndVisible];
What is mean by makeKey?
21
votes
4
answers
4k
views
UIStatusBarStyle changes after displaying a UIWindow over UIStatusBar
I am displaying a UIWindow over the UIStatusBar, by default the UIStatusBarStyle is set to UIStatusBarStyleLightContent, but when I display the UIWindow the UIStatusBarStyle switches to the black ...
18
votes
6
answers
16k
views
UIWindow with wrong size when using landscape orientation
I have an empty application and there is no storyboard or xib involved. I want to have a hidden status bar and support only landscape orientation. Again, I wan't to make those changes only within code ...
18
votes
3
answers
537
views
Resize a UIView to allow space for ad unit
I am trying to add an ad unit above a subclass of UIView RCTRootView. This would move the RCTRootView down about 50px. This is my current attempt.
RCTRootView *rootView = [[RCTRootView alloc] ...
16
votes
1
answer
7k
views
What does setting the UIWindow's rootViewController do?
Assigning a view controller to this property (either programmatically
or using Interface Builder) installs the view controller’s view as the
content view of the window.
The above quote is from ...
16
votes
4
answers
13k
views
Custom UIWindows do not rotate correctly in iOS 8
Get your application into landscape mode and execute the following code:
UIWindow *toastWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
toastWindow.hidden = NO;
toastWindow....
15
votes
1
answer
10k
views
After rotation UIView coordinates are swapped but UIWindow's are not?
Using Xcode 4.2.1 iPad iOS 5.0.1, create a new "Single View" iPad project. In the controller, add:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
...
15
votes
7
answers
19k
views
Capturing full screenshot with status bar in iOS programmatically
I am using this code to capture a screenshot and to save it to the photo album.
-(void)TakeScreenshotAndSaveToPhotoAlbum
{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
if ([[...
15
votes
3
answers
6k
views
Why is AppDelegate.swift window an optional?
I was reading Apple docs, when I found this sentence:
The AppDelegate class contains a single property: window.
var window: UIWindow?
This property stores a reference to the app’s window. This window
...
14
votes
3
answers
2k
views
UIWindow not filling screen for new devices?
I'm working with an old Xcode project which is roughly 7/8 years old and I've migrated it to Objective-C 2.0 and to support ARC. The project didn't support Auto-Layout (this was just before it was ...
14
votes
1
answer
3k
views
Where can I change the window my app uses from UIWindow to my own subclass "MyWindow" with storyboard?
I've got a universal project here with storyboard. I've created a subclass of UIWindow called MyWindow, and I need to load it instead of the default UIWindow. Prior to storyboard, I would simply go to ...
14
votes
1
answer
25k
views
The app delegate must implement the window property if it wants to use a main storyboard file
I'm programmatically implement a list view controller.
When I try to run the project, I got error:
2012-11-07 22:46:34.719 myTableViewControl[12021:c07] The app delegate must implement the ...
14
votes
2
answers
9k
views
App called -statusBar or -statusBarWindow on UIApplication
I'm trying to build my app with Xcode 11 beta 6 and iOS 13 beta 8 but it throws this error once it starts to run:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', ...
13
votes
1
answer
2k
views
How did Vesper show users wallpaper without UIApplicationIsOpaque key?
An app named Vesper was updated for iOS 7 and shows the user's wallpaper on iOS 7. I have found that using UIApplicationIsOpaque key and UIBackgroundStyleLightBlur can show the users background but ...
12
votes
1
answer
14k
views
makeKeyWindow vs makeKeyAndVisible
What is the difference between makeKeyWindow and makeKeyAndVisible which are two methods of UIWindow ?
When will a UIWindow be a keyWindow but will not be visible?
12
votes
6
answers
13k
views
Dismiss all UIAlertControllers currently presented
Is there a way to dismiss all UIAlertControllers that are currently presented?
This is specifically because from anywhere and any state of my app, I need to get to a certain ViewController when a ...
11
votes
5
answers
14k
views
Set rootViewController iOS 13
After upgrading Xcode a critical part of my application has stopped working.
When my app launches I run a function to check boolean flags and set the correct rootViewController.
But the code I have ...
11
votes
3
answers
3k
views
Manually Created UIWindow is Wrong Size
I am learning how to create an iOS app without Interface Builder (i.e. storyboards, xibs, etc.). Below is the basic app delegate class I am working with. The problem is that when displayed the ...
10
votes
3
answers
8k
views
What is the purpose of UIWindow?
I've always seen references to an app's 'window', and I see that AppDelegates usually have a UIWindow property called 'window'. So I'm just wondering how to perceive this UIWindow object. I see that ...
10
votes
1
answer
2k
views
How to detect window resizing in Mac Catalyst?
How can I a get a notification when user resize the window while:
NotificationCenter.default.addObserver(self, selector: #selector(function), name: NSWindowDidResizeNotification, object: nil)
is ...
10
votes
4
answers
12k
views
Xcode 11 beta: AppDelegate file doesn't have window global variable
I am facing an issue in Xcode 11 beta.
The problem is that I am not getting default window variable declared in AppDelegate file.
Is anybody facing this same issue?
10
votes
1
answer
256
views
How can Window from Object Library in Interface builder be used
I've been doing iOS developement for a while but never used or seen someone using the Window object. I tried googling about it but I did not found any relevant articles. I know about 'UIWindow' object ...
9
votes
8
answers
28k
views
How to add view in UIWindow?
I wanted to add a view in UIWindow with following code:
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
UIWindow *window = delegate.window;
UIView *aView = [[...