I am attempting to create an unwind segue but nothing will connect to it when ctrl+dragging. Also when I right click on the Exit icon there are no options available.
Any ideas?
I am attempting to create an unwind segue but nothing will connect to it when ctrl+dragging. Also when I right click on the Exit icon there are no options available.
Any ideas?
You need to have an IBAction defined on a view controller that takes an argument of type "UIStoryboardSegue *".
Something like this:
@interface MyViewController
...
- (IBAction)unwindFromConfirmationForm:(UIStoryboardSegue *)segue {
}
...
@end
Swift 3 Version
@IBAction func unwindToViewController(segue: UIStoryboardSegue) {
//code
}
Provided by DoruChidean in https://mcmap.net/q/102538/-cannot-connect-storyboard-unwind-segue
done:(id)sender
. –
Dispassion Just to clarify, to link this up in storyboard, after adding the above method to the "view controller you want to unwind to" you need to drag a segue from a button or whatever in your "view controller you want to unwind from" down to it's own little green "EXIT" icon in the bottom bar.
There should be a popup to link to "- unwindFromConfirmationForm".
Once that's done, the unwind segue should work.
Just adding to Travis excellent point: to be utterly clear:
Say you've just started experimenting with storyboards so you (a) made a new iOS7 Xcode project and (b) made a story board with one navigation controller, and then (c) you've made five or six view controllers. You aim to be able to go-and-fore between the half-dozen view controllers using unwinds. {It is trivial to go "forward" by control-dragging from a button in one, to, the next one.}
Now, at this moment: all six of the view controllers, will indeed be the "default" class "ViewController". Note that Xcode (somewhat pointlessly) gives you a ViewController.h and ViewController.m file.
Again, all six of your "simple example" views are indeed just using that file ViewController.m, at this moment. So, very simply, if you add this:
-(IBAction)unwindUnused:(UIStoryboardSegue *)segue
{
NSLog(@"I did an unwind segway! Holy crap!");
}
To that one "stub" file ViewController.m - in fact, every one of your six views will now "work", you'll be able to drag to the infamous small green "Exit" button. It's that easy.
Now just TBC normally in a real project, you'd never use the default "ViewController.m" file. So, go here:
and find down to precisely "Create Custom View Controllers", and it of course explains that process in excellent detail if you're new.
But again, if you're just fooling around and want to make the green button work for unwinds, simply put the code fragment in the "ViewController.m" stub file, and you're away. (Remembering that in "real life" you'd put a custom such call in each of your custom screens - likely dealing with data, etc etc.) Hope it helps!!
Bonus factoid: Note that a "Back" button will, anyway, automatically appear on the navbar when you're just testing like this! (i.e., even if you don't add the unwind stub method.)
Upvote for Jon Hess! This is the swift 3 equivalent
@IBAction func unwindToViewController(segue: UIStoryboardSegue) {
//code
}
Are your working with xcode6-beta version? in beta 1-3 is a bug which prevents interface builder from detecting unwind segues. in xcode6-beta4 this bug has been fixed.
© 2022 - 2024 — McMap. All rights reserved.