corin8823 / Popover

Popover is a balloon library like Facebook app. It is written in pure swift.
MIT License
2.1k stars 327 forks source link

Popover only shows up after a transition or alert in the same view controller #78

Closed likeaj6 closed 7 years ago

likeaj6 commented 7 years ago

I noticed that the popover in my app wasn't showing consistently. I kept playing around and figured out that the popover only starts appearing after a transition or alert(perhaps other conditions can work too, but these are the only two I've found so far) on the view controller has occurred.

Other UI changes such as changes in frames of the embedded views in the view controller don't affect it at all. I stepped through the popover initialization in the debugger and any popover before an alert or transition would have a containerView and contentViewFrame that are both nil.

Perhaps has to do with the view/window that popover is presenting from? How can I fix this?

likeaj6 commented 7 years ago

Was able to fix by changing this line in the show function of the Popover

guard let rootView = UIApplication.shared.windows.last ?? UIApplication.shared.keyWindow else { return }

changed to

guard let rootView = UIApplication.shared.keyWindow else { return }