Skip to content

Commit

Permalink
Merge pull request #66 from jimmaye/keywindow-fix
Browse files Browse the repository at this point in the history
Bugfix for PR #63
  • Loading branch information
corin8823 committed Apr 10, 2017
2 parents 882b764 + 8e96460 commit 4d178a5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Classes/Popover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ open class Popover: UIView {
}

open func showAsDialog(_ contentView: UIView) {
self.showAsDialog(contentView, inView: UIApplication.shared.windows.first!)
guard let rootView = UIApplication.shared.windows.last ?? UIApplication.shared.keyWindow else {
return
}
self.showAsDialog(contentView, inView: rootView)
}

open func showAsDialog(_ contentView: UIView, inView: UIView) {
Expand All @@ -185,7 +188,10 @@ open class Popover: UIView {
}

open func show(_ contentView: UIView, fromView: UIView) {
self.show(contentView, fromView: fromView, inView: UIApplication.shared.windows.first!)
guard let rootView = UIApplication.shared.windows.last ?? UIApplication.shared.keyWindow else {
return
}
self.show(contentView, fromView: fromView, inView: rootView)
}

open func show(_ contentView: UIView, fromView: UIView, inView: UIView) {
Expand All @@ -205,7 +211,10 @@ open class Popover: UIView {
}

open func show(_ contentView: UIView, point: CGPoint) {
self.show(contentView, point: point, inView: UIApplication.shared.windows.first!)
guard let rootView = UIApplication.shared.windows.last ?? UIApplication.shared.keyWindow else {
return
}
self.show(contentView, point: point, inView: rootView)
}

open func show(_ contentView: UIView, point: CGPoint, inView: UIView) {
Expand Down

0 comments on commit 4d178a5

Please sign in to comment.