Unwind Segue Xcode 6.1 Swift - ios

I know this was a problem in the Xcode betas and I read that this was fixed in the Xcode 6 GM, but I am having trouble with it now. I have create an unwind segue but it doesn't unwind properly. I have both views set to their respective custom View Controller, I have the unwind function in the view controller I want to unwind to, and this is the code I'm using:
#IBAction func unwindToObjectives(segue: UIStoryboardSegue) {
}
Can someone please help explain what I'm doing wrong? I know there is a work around, but I am trying to avoid using it. Also, I apologize for asking this menial question, I'm extremely new to Swift and iOS development.

I fixed the problem. In the end I just remade the custom TVC (with the segue), deleted the VC, and change the segue to a modal on and it work. I don't know how that helped, but it did.

Related

unwind to other viewController without using StoryBoard

I am use to performing unwinds to the easy what that is like this:
First set this on the destination view controller:
#IBAction func unwindToThisViewController(segue: UIStoryboardSegue) {}
Finally drag and drop and then pick the wanted unwind:
But till Xcode updates to 8.2.1 if you have the destination view controller with some extensions it doesn't appear on the list (Manual Segue). I didn't update to 8.3 because I'm still using Swift 2.3 so I don't know in further versions this bug is solved.
Instead of having to move all the extensions in the same file, which it will be a chaos find anything there. I am wondering if there is any other way to perform this action without using the storyboard step.
I am currently using navigation controller, maybe popToViewController will do it? I don't know honestly.
Thank you very much for the help.
In the storyboard, give your unwind segue an identifier.
Then, in your code do:
performSegue(withIdentifier: "SegueID", sender: nil)
Source: https://spin.atomicobject.com/2014/12/01/program-ios-unwind-segue/

Xcode 8 beta 6 unwind segue seems broken because "WithSegue" is added to #IBAction unwind method name automatically

I just realised that, in the current Xcode 8 beta 6, when I hook up an unwind action to, e.g., a bar button item in a modally presented view controller to unwind the modal presentation segue and present the view controller previously in the navigation stack, Xcode adds an "WithSegue" to the name of the existing #IBActions that can be used for this purpose - and that this breaks the unwind segue (it won't be performed). If I edit the storyboard file in source code (as XML), and remove this "WithSegue" from the #IBAction method identifier, the segue works as expected. For example, my unwind method in the originating view controller (the destination for the unwind segue) is called "unwindFromSettingsToTableView" - and Xcode/Interface Builder rename this method to "unwindFromSettingsToTableViewWithSegue" when I CTRL-connect the bar button item in the modally presented view controller to the view controller's exit item in the scene dock.
Is this a bug in Xcode 8 beta? Is it a known bug? Am I missing something?
I checked my previously connected unwind segues (connected in Xcode 7), and they don't have this "WithSegue" suffix. If I delete those existing "vintage" unwind segues, and connect them again in Xcode 8, Interface Builder now suggests the same method name with the "WithSegue" suffix - and those segues break. When I delete the suffix in storyboard source code, the unwind segue works again.
Would be great to get any indications. This behaviour is annoying.
Best wishes!
Björn
In Swift 3, if you don't want it to add WithSegue, define your #IBAction method to not name the first parameter:
#IBAction func unwindHome(_ segue: UIStoryboardSegue) {
// this is intentionally blank
}
If you don't use that _ syntax, when it goes to hook up the #IBAction, it will add the WithSegue to the name.
When I use the above syntax for my unwind action, it works fine in Xcode 8, beta 6.
As an aside, when I don't use the _ syntax shown above in beta 6, it names the action unwindHomeWithSegue but it still works with that longer name, with no editing of the storyboard XML needed. I wonder if your non-functioning unwind segue is a result of some other issue. We need a reproducible example of the problem to diagnose further. Perhaps you can share a MCVE.
I had the same issue as OP, using swift 2.3 in xcode 8 beta 6.
This post using ios 8 explained how to unwind the segue programmatically. And in step three to select the unwind segue in the Document Outline.
Selecting this and changing unwindToSecondVCWithSegue in Action on the upper right side to unwindToSecondVC so it matches the code solved my issue.
#IBAction func unwindToSecondVC (segue: UIStoryboardSegue) {
print("unwindToSecondVC")
}
This problem still occur with the released version of Xcode 8.0 not just the betas.
What I noticed in an unwind segue though is that the suffix was "WithUnwindSegue" instead of "WithSegue"
I too was using an swift 2.3 project and created an unwind segue. Similar to the above, while on the storyboard, the fix is to remove WithUnwindSegue suffix in the Action property (field) of the segue's Attributes Inspector.

How to get unwind segue without animation?

I am new to iOS app developing.
I want an unwind segue without any animation, but I don't know how to get that. Could anybody help me out???
Thanks a lot!!
If you just need to remove the last viewController displayed from your navigation stack you can use [self.navigationController popViewControllerAnimated: NO];
I think, you should perform custom animation for unwind segue.
and don't animate your VC in that animation.
Try this to perform Unwind segue with animation: http://spin.atomicobject.com/2015/03/03/ios-unwind-segue-custom-animation/
I'm searching for an answer to this as well. The one thing I do know, which hasn't been mentioned yet, is that in Xcode 7 there's a new box you can uncheck.
Go to the storyboard and select the unwind segue. In the inspector you where the ID and class are, below the text fields there's now a checkbox which says "Animates". You can uncheck it, telling it not to animate the unwind.
Too easy, right? Yup. The catch is that it's new and only works for iOS9. If you're targeting anything earlier, you need a different solution.

Programmatically calling performSegueWithIdentifier does nothing

I am in a situation exactly like this post, but for whatever reason, only one of my performSegueWithIdentifier:sender works.
I have a View Controller (embedded in a UINavigationController) with two buttons, Cancel and Done. When clicked I want Cancel to unwind to one screen, and Done to unwind to another screen; however, this only works with one of the two segues I have set up.
- (IBAction)clickedDone:(id)sender {
[self performSegueWithIdentifier:#"unwindToHome" sender:self];
}
- (IBAction)clickedCancel:(id)sender {
[self performSegueWithIdentifier:#"unwindToViewEntries" sender:self];
}
"unwindToHome" works fine while "unwindToViewEntries" does nothing. No error, no printing, nothing. If I switch the segues and buttons, "unwindToHome" will still work while "unwindToViewEntries" does nothing.
I have unwind methods in both ViewControllers I want to unwind to and there are no other actions attached to the buttons.
I find it really odd that only one works. I've looked them over several times and there is nothing different that I can see.
Thanks in advance for the help. If there are some more things I should check please let me know!
I've already looked at solutions for the following posts:
How to unwind programmatically to 2 different VC
performSegueWithIdentifier not working
I've also tried removing the segues and re-adding them, as well as deleting and re-adding the entire view controller. Every time, the same behavior.
EDIT: I should also mention that I've tried adding other segues in different views and none of the new ones I add work. Only "unwindToHome" seems to work, and I can't figure out why.
In the storyboard make sure that both segues show that it is a show (push) segues. There was a question earlier,which is a little bit different, that if you create two segues from the same button Xcode was setting one push the other modal.
Happy coding!
Yan

Unwind Segues not working on Xcode 6

I just downloaded Xcode 6.0.1, and I tried running my app in the simulator. All of my unwind segues are not working. All of my code is in Objective-C, I have NO Swift whatsoever. The segues worked perfectly fine before I updated Xcode.
Am I the only one with this problem?
UPDATE: This has been fixed with the release of iOS 8.1.x
After a lot of fiddling around with this, my experience is that only view controllers presented modally are affected by this issue. The work around in this case is to set your segue presentation to Current Context instead of Default.
Credit to this SO poster https://stackoverflow.com/a/25842508/401092
This was a bug affecting iOS 8.0(and .1 and .2) - view controllers presented modally wouldn't perform unwind segues - the unwind method wouldn't be called.
This issue appears to be fully resolved with iOS 8.1 beta. Note that iOS 8 doesn't automatically dismiss the modally presented view controller while on iOS 7 it does, so if you need to support both you'll want to detect if it's being dismissed in the unwind method and if it's not then manually dismiss it.
It worked for me!
So in my case I had a view controller presented modally and when I wire an unwind segue to a button, the prepareForSegue method was never called and the unwind method in the root controller never called neither.
Change to current context and everything is working.
Thanks

Resources