-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added rotation support by placing the messages in the rootViewController... #29
Conversation
…ler of their own window. Added rotation notification to resize messages on rotation
Excited for this fix Daniel! Minimal amount of code change is always nice I cloned your fork and ran the demo app and can't seem to present any of the messages. showMessage is fired, etc but nothing appears. Can you confirm? |
…tes _messageWindow loading below the sharedApplication keyWindow.
Apologies Terry, I had not tried the changes in the demo app. I've pushed a fix to master. Here's the commit for reference DanielKrofchick@dc7a5a2. It appears that the messageWindow was loading behind the keyWindow, obscuring the messages. I'm assuming the messageWindow is loading first, but that is a bit odd. The solution was to lazy load the messageWindow on first access to keyWindow. I'm not aware how to enforce an order for windows, which I think would be preferable. |
Ah, I was trying to figure out how the message was able to orient itself properly if the messageBarOffset was hardcoded to 0.0; then I realized it was re-positioned inside the root view. Clever. I like this implementation. Very clean. One q: why is the TWTouchForwardingWindow never added a subview? How can it absorb touches and pass them through? How can the root controller's view even show anything? Confused on the magic behind this. |
Added rotation support by placing the messages in the rootViewController...
Yeah it is a bit odd, but windows are not added to screens. By default they are associated with the main screen, and all you have to do is set hidden = NO. The touchForwardingWindow returns nil when it's rootViewController's view is hit (it's subview's were missed), and this passes touches on to the next window. If a subview is hit, a TWMessageView, we return it, and it receives the touch. |
Guess I learned something new today. Good stuff @DanielKrofchick, thanks for the contribution. I pulled it in this AM; works great! |
... of their own window. Added rotation notification to resize messages on rotation
These changes add rotation support. For notifications to rotate properly (without resorting to complicated transforms) they need to be a subview of a window's rootViewController. However adding it to the sharedApplication's keyWindow rootViewController causes problems with notifications appearing behind modal controllers that are presented. The best solution is to create another window on top, and add the notifications to it's rootViewController. The last trick is to handle touches for the message views, but pass all other touches to the window below.
This has been tested on iOS 6.1 and 7.1. And works with all rotations on the iPad. I haven't tested rotations on the iPhone, but I don't see why it wouldn't work there as well.
I left the keyWindow naming, although it does now return a view.