pkluz / PKHUD

A Swift based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8.
MIT License
3.79k stars 494 forks source link

running error Unexpectedly found nil while unwrapping an Optional value #237

Open tuotuoZ opened 6 years ago

tuotuoZ commented 6 years ago

I am testing out the HUD.flash(.success, delay: 1.0) in a new class. And I got this running error: Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value

from line 122 let view: UIView = view ?? viewToPresentOn ?? UIApplication.shared.keyWindow!

Kamil-H commented 6 years ago

@tuotuoZ I don't know your exact case, but in mine using a onView parameter function where you can provide UIView on which you want to show dialog helped me. In your case it would be: HUD.flash(.success, onView: **view**, delay: 1.0, completion: nil) where view is a root view of my ViewController.