2014-10-17 3 views
1

UIAlertViewController отображает весь текст, но при нажатии не переключается на другой вид. Вот код:Как изменить Открыть, щелкнув по кнопке в UIAlertViewController

let alertController = UIAlertController(title: "Risposta Esatta", message:"",  preferredStyle: UIAlertControllerStyle.Alert) 


    alertController.addAction(UIAlertAction(title: "Avanti", style:UIAlertActionStyle.Default,handler: {(UIAlertAction) in 
     let secondViewController:SecondViewController = SecondViewController() 
     self.presentViewController(secondViewController, animated: true, completion: nil) 
    })) 
+0

Можете ли вы подтвердить, что это уволили? – Aggressor

ответ

0

Это просто работал для меня:

@IBAction func choiceBtn(sender: UIButton) { 
     let alertController = UIAlertController(title: "Hello!", message: "This is Alert sample.", preferredStyle: .Alert) 
     let otherAction = UIAlertAction(title: "OK", style: .Default) { 
      action in println("pushed OK!") 
     } 
     let cancelAction = UIAlertAction(title: "CANCEL", style: .Cancel) { 
      action in self.performSegueWithIdentifier("VC2", sender: self) 
     } 

     alertController.addAction(otherAction) 
     alertController.addAction(cancelAction) 
     presentViewController(alertController, animated: true, completion: nil) 
    } 

Я создал модальное подарил SEGUE от VC1 к VC2, а также с именем идентификатор VC2. Этот код я адаптировано из примера GitHub UIAlertController здесь:

https://github.com/eversense/Swift-UIAlertController-Example

Там не было никакого другого перехода к ViewController, так что я добавил, что, чтобы показать вам.

Смежные вопросы