Hello, I'm building an app that requires an alert to appear as soon as the user accesses the screen.
For this I did a ViewController and linked the view that is being accessed
class EducacaoController : UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let alert = UIAlertController(title: "Atenção!", message: "oi", preferredStyle: .alert)
let acaoAvançar = UIAlertAction(title: "Avançar", style: .default, handler: nil)
alert.addAction(acaoAvançar)
self.present(alert, animated: true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Apparently I believe you are right, but always present the message on the console:
2017-06-09 11: 30: 53.377951-0300 EsoEBrasil [599: 216652] Warning: Attempt to present on whose view is not in the hierarchy!