Galera,
Estou tentando fazer um loading e ao desaparecer o loading eu exibo um modal, porem ate agora sem sucesso, estou pegando esse erro:
Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior
Eu dei uma resumida no fonte pra ficar mais facil o entendimento:
@IBAction func btnEnrollDevice(sender: AnyObject) {
showProgress("Loading...")
clear()
}
func clear() {
dismissProgress()
showAlertDefault("Alert", message: "All the preferences were clear!")
}
func showProgress(title: String) {
UIApplication.sharedApplication().networkActivityIndicatorVisible = true
let indicator: UIActivityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.Gray)
let alert : UIAlertController = UIAlertController.init(title: nil, message: "Please wait...\n\n", preferredStyle: .Alert)
indicator.frame = alert.view.bounds
indicator.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
alert.view.addSubview(indicator)
self.presentViewController(alert, animated: true, completion: nil)
indicator.startAnimating()
}
func dismissProgress() {
UIApplication.sharedApplication().networkActivityIndicatorVisible = false
let indicator: UIActivityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.Gray)
self.dismissViewControllerAnimated(true, completion: nil)
indicator.stopAnimating()
}
Alguem tem alguma ideia?
Valeu galera