Skip to content

Commit

Permalink
fix keyWindow nil crash
Browse files Browse the repository at this point in the history
keyWindow may be nil on iOS 15, this is a simple fix
  • Loading branch information
kevin-zqw committed Oct 14, 2021
1 parent 8fd26f2 commit 597e660
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion PKHUD/PKHUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ open class PKHUD: NSObject {
open var trailingMargin: CGFloat = 0

open func show(onView view: UIView? = nil) {
let view: UIView = view ?? viewToPresentOn ?? UIApplication.shared.keyWindow!
guard let view: UIView = view ?? viewToPresentOn ?? UIApplication.shared.keyWindow else {
return
}
if !view.subviews.contains(container) {
view.addSubview(container)
container.frame.origin = CGPoint.zero
Expand Down

0 comments on commit 597e660

Please sign in to comment.