custom UIWindow orientation
I needed to see touch events on my window, so I subclassed UIWindow to make my a MYWindow class. I am overriding the sentEvent function to receive the touch events on the window and all of that is working just fine. I did the following to achieve this:
self.window = [[MYWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window makeKeyAndVisible];
The issue I am facing is that when I do this, the viewControllers that are on this window won't rotate anymore. If I were to use a regular UIWindow, they all work just like I intended them to work. Obviously, something is wrong with my开发者_Python百科 setup.
I was looking through UIWindow header file and there is a method called
- (void)becomeKeyWindow; //override point for subclass, Do Not call directly
Am I suppose to implement this in my custom UIWindow class just like I had to implement the sendEvent: method? Please point me in the right direction with this.
Thanks in advance guys.
I figured out what the issue was. I was creating a delegate on the custom window and called it "delegate" which was causing the issue. Naming it to "aDelegate" solved the issue. thanks for all your help.
I'm only guessing here, but I'd presume it is because you made MYWindow
the key window now (even if it is transparent) and shouldAutorotateToInterfaceOrientation:
is part of UIViewController
class, not UIWindow
.
So even though you can see your other views, they are not getting their rotation events called on them anymore.
Instead of making it a UIWindow
subclass, why not implement those touch events on a UIView
that gets added to your view that needs the touch events handled? You can make it transparent as well, and just keep the rotation handled at the UIViewController
level?
精彩评论