Help us understand the problem. What is going on with this article?

複数画面A、Bから呼ばれる画面Cを閉じた時にunwindを使って遷移元に戻す方法

More than 3 years have passed since last update.

やりたいこと

複数画面A、Bから呼ばれる画面Cを閉じた時にunwindを使って遷移元に戻す。
遷移元の「@IBAction func unwind(segue: UIStoryboardSegue)」で処理を行いたいので「dismissViewControllerAnimated」は使いたくない。

画面

スクリーンショット 2016-02-15 14.36.10.png

左上:画面A 右上:画面B 下:画面C

やり方

単純に「@IBAction func unwind:」の名前を同じにするだけでできた。
ここまで辿り着くのに凄い時間かかったよorz

画面A
class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func unwind(segue: UIStoryboardSegue)
    {
    }

    @IBAction func click(sender: UIButton)
    {
        self.performSegueWithIdentifier("toC", sender: nil)
    }

    @IBAction func click2(sender: UIButton)
    {
        self.performSegueWithIdentifier("toB", sender: nil)
    }
}
画面B
class View2Controller: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func unwind(segue: UIStoryboardSegue)
    {
    }

    @IBAction func click(sender: UIButton)
    {
        self.performSegueWithIdentifier("toC", sender: nil)
    }
}
画面C
class View3Controller: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした