2017-02-02 5 views
0

ユーザーが「:(」(UIAlertのボタン部分)をクリックした後に私のホーム画面にセグをしたいのですが、「:(」、私はUIAlertを削除し、のみセグエを持っている場合。変更されませんが、この方法は、ホーム画面にseguesことで動作します。私が行うことができますどのように両方の?同じメソッドのアラートとセグが一緒に機能しない

あなたのアクションで performSegueする必要があることについては
let gameOver = UIAlertController(title: "BOOM", message: "You hit a mine! Game over.", preferredStyle: UIAlertControllerStyle.alert) 
gameOver.addAction(UIAlertAction(title: ":(", style: UIAlertActionStyle.default, handler: nil)) 
self.present(gameOver, animated:true, completion: nil)  
self.performSegue(withIdentifier: "homeScreen", sender:self) 

答えて

1

現在、あなたはそれをゼロに設定しています。

let gameOver = UIAlertController(title: "BOOM", message: "You hit a mine! Game over.", preferredStyle: .alert) 
gameOver.addAction(UIAlertAction(title: ":(", style: .default) { action in 
    self.performSegue(withIdentifier: "homeScreen", sender:self) 
}) 
self.present(gameOver, animated:true) 
関連する問題