uiwindow

iOS - UIEventTypeRemoteControl events not received

≡放荡痞女 提交于 2019-11-28 01:45:45
问题 I have this in the AppDelegate (didFinishLaunching): [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; I tried handling the events in the relevant view controllers but that was spotty (some view controllers would get the events and others wouldn't, even when they were first responders). I tried subclassing UIApplication. That didn't work. Now I'm trying to subclass UIWindow and do this (see the comments): - (void)sendEvent:(UIEvent *)event { if (event.type ==

Capturing full screenshot with status bar in iOS programmatically

瘦欲@ 提交于 2019-11-27 20:39:24
问题 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 ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(window.bounds.size, NO, [UIScreen mainScreen].scale); else UIGraphicsBeginImageContext(window.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image =

Automatically Sizing UIView after Adding to Window

喜你入骨 提交于 2019-11-27 16:42:54
问题 Note: This may be a duplicate of Subview Doesnt AutoSize When Added to Root View Controller I have an iPad app that switches between different views in its main window. The view-switching code looks like this: - (void)switchToViewController:(UIViewController*)viewController { if (currentViewController != viewController) { [currentViewController.view removeFromSuperview]; currentViewController = viewController; [window addSubview:viewController.view]; } } The problem is that when the new view

Convert a UIView origin point to its Window coordinate system

╄→гoц情女王★ 提交于 2019-11-27 12:47:32
问题 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)+20(status bar height) = 115. Means in window coordinate system the scrollView.frame.origin should be (0,115). I tried with convertPoint: methods but getting (0,51) or (0,0) sometimes. Please provide a solution to this. Thanks 回答1: It sounds like your not converting between the proper views. A

iOS - Get location of a view in a window?

僤鯓⒐⒋嵵緔 提交于 2019-11-27 12:19:58
问题 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 to be relative to my UIView, so I need to know the relative location of my UIView in the window. Question: How can I find the location of a UIView in a UIWindow when the UIView is not directly in the UIWindow (It's inside the view of my viewController)? 回答1: Use can use the UIView method

How to disable long touch in UIWebView?

烂漫一生 提交于 2019-11-27 12:12:42
问题 I want to disable long-touch from the application. I have no control on the HTML that I am loading on my WebView. 回答1: In webViewDidFinishLoad delegate I run a javascript on the loaded html page that disable the long touch. [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none'; document.body.style.KhtmlUserSelect='none'"]; 回答2: You could try to override the following methods from the view controller : - (void)touchesBegan:(NSSet *)touches withEvent:

unexpected nil window in _UIApplicationHandleEventFromQueueEvent

时间秒杀一切 提交于 2019-11-27 12:03:13
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 well as a UINavigationController which has its first View Controller defined within as well. The image

To create a new UIWindow over the main window

纵饮孤独 提交于 2019-11-27 10:18:10
问题 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 then create a new UIWindow overlay, but nothing happens. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor redColor];

Get the top ViewController in iOS Swift

99封情书 提交于 2019-11-27 09:18:29
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 displayed in the foreground). I have found several gists which seem to solve my problem (see the code

subclassing UIWindow while using storyboards

a 夏天 提交于 2019-11-27 09:01:21
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 'window' getter method in my app delegate that returns 'MyWindow' subclass? Or maybe there is other ways to assign my subclass to my app's main window? UIWindow in a Storyboard project can be subclassed as explained in Apple's UIApplicationDelegate reference: window When a storyboard is being used, the application must present the storyboard by adding it to a window and putting that window on-screen. The