简体   繁体   中英

Unwind seg programmatically in Xcode6 and Swift

In destination screen, I put this:

@IBAction func unwindToLogin (segue : UIStoryboardSegue) {}

From storyboard view button for example, I can easily refer to this to unwind.

But I cannot do it programmatically. I tried to trigger this in current screen:

 performSegueWithIdentifier("unwindToLogin", sender: nil)

but it crashes because of nil. So it seems from storyboard "exit" I can 'catch' the unwind and link it to a button, but I can't do this programmatically.

Use Selector s:

Selector("unwindToLogin:")

By the way, Selector s should be automatically created from string s, so I think the problem is with the missing semicolon, but I haven't my Mac with me atm.

The name of the function you put in the destination view controller is not the identifier of the segue. You need to set the identifier in the storyboard, and use that string in performSegueWithIdentifier.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM