有人知道在使用 Xcode 4.5编辑情节串连图板时,新的 Exit 图标是用来做什么的吗?

右键单击 Exit 图标将生成一个空窗口。不能 Ctrl-拖动连接到任何 IB 元素或相应的源文件。医生不给爱。不出现在提示符文件中,只出现在故事板中。我的假设是,这是继续的必然结果,但我没有看到任何新的方法来支持它。有人吗?

30090 次浏览

There's a lot of information in the WWDC video "Session 407 - Adopting Storyboards in your App."

Say you have two view controllers linked by a segue. Implement the following exit action on the first view controller:

- (IBAction)done:(UIStoryboardSegue *)segue {
NSLog(@"Popping back to this view controller!");
// reset UI elements etc here
}

Then, on Storyboard scene for the second view controller, Ctrl-drag from a UI element, such as a button, to the exit icon at the bottom of this view controller. The done: action you added to the code of the first controller will appear as an option. Now, activating the button you Ctrl-dragged to the exit icon will pop back to the first view controller and maintain its original state (ie UI elements such as text input supposedly still intact).

I had a hard time following the accepted answer so here is more detail.

Given the photo below on view controller C you can "exit" back to any view controller in the segue path.

enter image description here

ViewController A you can write:

- (IBAction)done:(UIStoryboardSegue *)segue {
// Optional place to read data from closing controller
}

ViewController B you can write:

- (IBAction)back:(UIStoryboardSegue *)segue {
// Optional place to read data from closing controller
}

ViewController C you control drag from "back" button to the green exit option and select back: ViewController C you control drag from "done" button to the green exit option and select done: enter image description here

Note: Even though the methods are on other view controllers they show up for the ViewController C's exit. Control dragging and selecting a method defines which ViewController to unwind to.

As addition to Eric answer here is how it works with :

The function you add to the destination controller looks like:

@IBAction func backFromOtherController(segue: UIStoryboardSegue) {
NSLog("I'm back from other controller!")
}