O 'UIAlertView' foi descontinuado no iOS 9.0. Use UIAlertController com um preferência de estilo UIAlertControllerStyleAlert
Tenho mais respostas, mas nada ajudou. Aqui está o meu alerta e ação mais antigos para isso
override func viewWillAppear(animated: Bool) {
if Reachability.isConnectedToNetwork() == true {
print("internet connection ok")
} else
{
print("internet not ok")
let alertView: UIAlertView = UIAlertView(title: "Alert ", message: "connect to internet", delegate: self, cancelButtonTitle: "settings", otherButtonTitles: "cancel")
alertView.show()
return
}
}
func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int)
{
if buttonIndex == 0 {
//This will open ios devices wifi settings
UIApplication.sharedApplication().openURL(NSURL(string: "prefs:root")!)
}
else if buttonIndex == 1
{
//TODO for cancel
exit(0)
}
}
Nisso estou recebendo aviso:
O 'UIAlertView' foi descontinuado no iOS 9.0. Use UIAlertController com um preferência de estilo UIAlertControllerStyleAlert
Eu tentei :
let alert = UIAlertController(title: "Alert", message: "My Alert for test", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: { (action:UIAlertAction!) in
print("you have pressed the Cancel button")
}))
self.presentViewController(alert, animated: true, completion: nil)
Mas, para adicionar dois botões e adicionar o caminho do índice do método de pressionar o botão vincular meu código mais antigo, não consigo fazer isso. Nada acontece no meu botão de inserção,
Por favor me ajude, como posso remover esses avisos e recodificar meu Uialert com minha ação de dois botões.
Eu sou novo no swift.Sua ajuda será útil.Obrigado!