2017-09-30 4 views
0

私は3つのViewControllerを持っています。 Okアラートが表示されたボタンをクリックすると、ThirdViewControllerからSecondViewControllerにセグを実行したいです。私はすでにこのコードを試してみました:Xcode Swiftは警告付きのセグを実行します

alert.addAction(UIAlertAction(title: "Ok!", style: UIAlertActionStyle.default, handler: { action -> Void in 
    self.performSegue(withIdentifier: "ThirdViewControllerSegueBack", sender: self) 
})) 

問題はSecondViewControllerの新しいウィンドウが現れるということですので、私はそれが戻っThirdViewControllerに私をリードし、ナビゲーションバーのbackをクリックしたとき。 FirstViewControllerを表示します。あなたがアンワインドを作成する必要がありますSecondViewControllerで

+2

あなたはリラックスしたセグを必要とします:https://stackoverflow.com/questions/12561735/what-are-unwind-segues-for-and-how-do-you-use -them – Shades

+0

ご使用のシナリオで動作する場合は試してください:https://stackoverflow.com/questions/45792130/unwind-then-segue-without-showing-intermediate-view-controller/45792543#45792543 – Amit

+0

これを見てくださいハウツー:(巻き戻し)https://medium.com/@mimicatcodes/create-unwind-segues-in-swift-3-8793f7d23c6f – AlexWoe89

答えて

0

は、ボタンを終了し、セグエを追加するのViewControllerからViewController3ドラッグでストーリーボードに

@IBAction func unwindToController2(segue:UIStoryboardSegue) { } 

をセグエ。それに識別子を追加し、UIAlertControllerを呼び出してください。 enter image description here

+0

ありがとうございます –

+0

@ lolinger2001あなたはようこそ)正しい答えを確認してください) – maxkoriakin

関連する問題