Open shyal opened 9 years ago
Thanks for the pull request. I appreciate it.
Are you trying to show other UIViewControllers in the window that DBAlertController creates, or are you trying to create multiple UIWindows? I'm not sure what issue you're running into. Can you elaborate?
The UIWindow that was shown before presenting DBAlertController will become key and visible again when DBAlertController is dismissed. This is because there are no longer any strong references to DBAlertController's window and the window is deallocated.
Hi Dylan,
I’m actually using your script with a Eureka form:
import UIKit import Eureka public class DBFormController: FormViewController {
/// The UIWindow that will be at the top of the window hierarchy.
The DBAlertController instance is presented on the rootViewController of this window.
private lazy var alertWindow: UIWindow = {
let window = UIWindow(frame: UIScreen.mainScreen().bounds)
window.rootViewController = DBClearViewController()
window.backgroundColor = UIColor.clearColor()
return window
}()
Which is just a UIViewController. To my delight it worked, but I noticed that in doing so, I was unable to interact with the my UI after calling dismiss.
I thought it might be because my initial app’s window was no longer key (whatever key means), and it turned out my modification worked.
I’m pretty new to Swift, so me at this point having no idea what I’m doing remains a possibility.
I’ve got quite a few UIAlertControllers, and Eureka based popup windows that can all appear in quick succession, and sometimes overlap. To make matters worse this can happen over modal dialogs. I tried to work something out by making them appear via a queue mechanism, but it was too tricky, and DBAlertController saved the day.
I hope this explains things a little better.
Regards,
OSB
On 6 November 2015 at 18:06, Dylan Bettermann notifications@github.com wrote:
Thanks for the pull request. I appreciate it.
Are you trying to show other UIViewControllers in the window that DBAlertController creates, or are you trying to create multiple UIWindows? I'm not sure what issue you're running into. Can you elaborate?
The UIWindow that was shown before presenting DBAlertController will become key and visible again when DBAlertController is dismissed. This is because there are no longer any strong references to DBAlertController's window and the window is deallocated.
— Reply to this email directly or view it on GitHub https://github.com/dbettermann/DBAlertController/pull/7#issuecomment-154474175 .
Makes sense. It sounds like you still have a strong reference to DBFormController even after you dismiss it. That means that there's still a strong reference to the window and thus the window is still showing. So the reason you can't interact with the UI is because the window or the DBClearViewController is intercepting your touches.
In summary, both of your assumptions are right.
While your changes don't quite fix the problem, your idea is still correct. I'll have to think about this one. Thanks again.
Yeah I wasn't really expecting you to merge it anyway as it doesn't address any issues with your script anyway. A 'good to know' at best. Maybe should have just mailed you instead!
Take care.
On 6 November 2015 at 23:29, Dylan Bettermann notifications@github.com wrote:
Makes sense. It sounds like you still have a strong reference to DBFormController even after you dismiss it. That means that there's still a strong reference to the window and thus the window is still showing. So the reason you can't interact with the UI is because the window or the DBClearViewController is intercepting your touches.
In summary, both of your assumptions are right.
- It does have to do with the old window hanging around.
- This concept does apply to any subclass of UIViewController.
While your changes don't quite fix the problem, your idea is still correct. I'll have to think about this one. Thanks again.
— Reply to this email directly or view it on GitHub https://github.com/dbettermann/DBAlertController/pull/7#issuecomment-154562299 .
No problem. I'm sure someone else will find value in this conversation.
I'm going to keep this issue open until I figure something out.
DBAlertController can be used with more than just UIAlertController, but for this to work properly it requires setting the root window back to key and visible on dismiss. I'm using this code but please test thoroughly.