uiwindow

Getting reference to the top-most view/window in iOS application

时光怂恿深爱的人放手 提交于 2019-11-27 06:04:27
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 UIAlertView. When I init the manager that listens for NSNotification events and adds views in response, I need to get a reference to the top-most view in the application. This is what I have at the moment: _topView = [[[[UIApplication sharedApplication] keyWindow] subviews] lastObject]; Would this work for any iOS application or is their a safer/better way to get the top view? Usually that will give

Why is main window of type double optional?

女生的网名这么多〃 提交于 2019-11-27 04:21:40
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 and what does it mean and if put into a if let should I add one ! after it? if let view = UIApplication.sharedApplication().delegate?.window! My first though was to replace ? with a ! after delegate but that was not the solution. Rob Napier @matt has the details, but there is a (somewhat horrible, somewhat awesome) workaround. (See edit below, though) let window = app.delegate?.window??.`self`() I

makeKeyWindow vs makeKeyAndVisible

心不动则不痛 提交于 2019-11-27 02:43:36
问题 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? 回答1: Each UIWindow has a windowLevel. A window is displayed in front of each window with a lower level, and behind each window with a higher level. But what about two windows with the same level? The window whose level was set more recently is in front, by default. (“When a window enters a new level, it’s ordered in front of all

UIWindow with wrong size when using landscape orientation

半城伤御伤魂 提交于 2019-11-27 01:36:50
问题 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 and don't touch the Info.plist. Problem I create a UIWindow with a controller that says the only supported orientation is landscape. In that case my UIWindow is created in the dimension of portrait mode and doesn't rotate. The expected result would be a screen that is completely cyan. This is my

Making a button persistent across all view controllers

試著忘記壹切 提交于 2019-11-26 22:00:55
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 know the button ought to be stored in the AppDelegate, but I don't know what other view it would be sense to add it to except the window. One downside of adding it to the window is that when there's an app running in the background (ie Phone), the added status bar padding will push down the window. In general, adding it to the window seems to be a hacky solution -- any thoughts? Yes, adding it to the

iPhone - Get Position of UIView within entire UIWindow

荒凉一梦 提交于 2019-11-26 21:17:42
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 position of the UIView in the entire 320x480 co-ordinate system. For example, if the UIView is in a UITableViewCell it's position within the window could change dramatically irregardless of the superview. Any ideas if and how this is possible? Cheers :) That's an easy one: [aView convertPoint:localPosition toView:nil]; ... converts a point in local coordinate space to window coordinates. You can

Orientation in a UIView added to a UIWindow

本秂侑毒 提交于 2019-11-26 21:15:51
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 the associated image. The zooming is performing flawlessly, what I haven't been able to figure out is why the subview is still in portrait mode even though the device is in landscape. An illustration below: I do have a navigation controller but this view has been added to the UIWindow directly. dizy You can read about some of the possible causes here: Technical Q&A QA1688 - Why won't my

Advantages, problems, examples of adding another UIWindow to an iOS app?

谁都会走 提交于 2019-11-26 19:24:56
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, but I'm interested in: What could I potentially achieve with a second UIWindow that cannot be done in other ways? What can go wrong when using multiple UIWindow instances? I have seen that people use a 2nd UIWindow to display popover like views on iPhone. Is this a good way of doing it? Why? Why not? Are there other examples where it is making perfectly sense to have another UIWindow ? It's not

unexpected nil window in _UIApplicationHandleEventFromQueueEvent

半世苍凉 提交于 2019-11-26 15:52:41
问题 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 _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: <UIWindow: 0x7fe4d3e52660; frame = (0 0; 320 568); opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x7fe4d3e2c450>; layer = <UIWindowLayer: 0x7fe4d3e86a10>> I'm using an old style MainWindow.xib. In the MainWindow.xib is my Window object, as

Get the top ViewController in iOS Swift

你说的曾经没有我的故事 提交于 2019-11-26 14:37:51
问题 I want to implement a separate ErrorHandler class, which displays error messages on certain events. The behavior of this class should be called from different other classes. When an error occurs, it will have an UIAlertView as output. The display of this AlertView should ALWAYS be on top. So no matter from where the Error gets thrown, the topmost viewController should display the AlertMessage (e.g. when an asynchronous background process fails, I want an error message, no matter what View is