User Orientation UIWindow

I needed to see touch events in my window, so I subclassed UIWindow to make my MYWindow class. I override the sentEvent function to receive touch events in a window, and all this works fine. To do this, I did the following:

self.window = [[MYWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window makeKeyAndVisible];

The problem I am facing is that when I do this, the viewControllers that are in this window will no longer rotate. If I used the regular UIWindow, they all worked the same way I intended them to work. Obviously, something is wrong with my setup.

I was browsing the UIWindow header file, and there is a method called

- (void)becomeKeyWindow;  //override point for subclass, Do Not call directly

I assume to implement this in my custom UIWindow class in the same way as I had to implement the sendEvent method :? Please point me in the right direction.

Thanks in advance guys.

+3
source share
2 answers

I realized what the problem is. I created a delegate in a custom window and called it a "delegate" that caused the problem. Naming it in "aDelegate" solved the problem. thank you for your help.

+4
source

I just guess, but I can assume that now you have made the MYWindowkey window (even if it is transparent), but shouldAutorotateToInterfaceOrientation:is part of the class UIViewController, not UIWindow.

, , .

, UIWindow, UIView, , ? UIViewController?

0

Source: https://habr.com/ru/post/1756951/


All Articles