congnd / FMPhotoPicker

A modern, simple and zero-dependency photo picker with an elegant and customizable image editor
MIT License
765 stars 128 forks source link

crash in FMLoadingView #34

Closed engsulta closed 4 years ago

engsulta commented 4 years ago

crash fix replace old init method with this one private init() { if let rootVC = (UIApplication.shared.windows.first?.rootViewController) { self.transparentView = UIView(frame: rootVC.view.frame)

    } else {
        let windowFrame = UIApplication.shared.keyWindow?.frame
        self.transparentView = UIView(frame: windowFrame ?? .zero)
    }

    self.transparentView.backgroundColor = UIColor(white: 0, alpha: 0.4)

    self.indicator = UIActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 35, height: 35))
    self.indicator.center = self.transparentView.center
    self.indicator.color = .white

    self.transparentView.addSubview(self.indicator)
}
congnd commented 4 years ago

How can I reproduce the crash?

congnd commented 4 years ago

Close due to long time no response. Feel free to reopen it again if you still need supports.

naveedmcs commented 2 years ago

--FMWarningView

let rootVC = (UIApplication.shared.delegate?.window??.rootViewController)! 
crashed 

Thread 1: Swift runtime failure: force unwrapped a nil value

naveedmcs commented 2 years ago

here is the solution

comment this line // let rootVC = (UIApplication.shared.delegate?.window??.rootViewController)! // update line number 30 with this below line
self.containerView = UIView(frame: UIScreen.main.bounds)