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
Related
I have been working on an app which has a slide menu which is there for an easier travel from vc to vc. Here I found a tutorial on how to implement the menu, but I have problem to switch vc's, bcs I don't know how to connect them without getting errors. What I have tried so far:
All VCs to the menu and from the menu to the VCs. This worked, kinda, but I am getting the error: ...whose view is not in the window hierarchy!
From the menu to all VCs with unwind instead of a separate segue. Here I have a problem, where I don't know how to get to the menu... I tried to unwind it, but that also doesn't make sense, bcs I haven't performed a segue before it.
Here is how I have done the linking so far:
Thanks for your help.
I think you should download full example from git. And review finished project carefully.
The error what you got related that in some time you remove your root view controller or try to push without any navigation controller.
The better way if you will use the similar scheme, where navigation controller is a root controller.
I have the following storyboard structure:
Essentially I have a UIButon that I want to link to the "TargetTableViewController" via an IBAction - NOT by 'Ctrl+Dragging' but programatically by way of some code instead.
I believe I have to present "NavViewControllerTwo" as a NavigationController (as it 'holds' "HoldingViewController") and have tried various renditions of this via the many threads at StackOverflow. But this did not work.
I suspect it is because the actual "TargetTableViewController" is embedded in a ContainerView of "HoldingViewController" and that causes the problems.
I have tried implementing other renditions of presenting "TargetTableViewController" as a child of the "HoldingViewController", but that caused me more problems.
I realise I may have over-complicated things here, but the reason for the container is I want to display a BannerView at the bottom of my eventually presented view.
If anyone can be kind to point me in the right direction, I will be very grateful. Thank you for your time.
** CLARIFICATION **
I am actually trying to present "HoldingViewController" as that would effectively display my "TargetTableViewController".
Please refer to amended image below:
Apologies for the confusion and lack of clarification.
Setup a segue from MainViewController to NavViewControllerTwo in the storyboard, give it an identifier and then perform that segue from your code on the button press action using [self performSegueWithIdentifier...
I'm using a weird setup in my splitview Ipad app where i need some help with.
I have a TVC and a Normal View side by side in the split view. When i select something in my TVC both the screens segue to another TVC and Normal View. This part works fine. I'm using the push method with destination Master Split & Detail Split.
The problem is going back. I want to press 1 button and unwind both segues. I do this by this method: https://github.com/bradley/iOSUnwindSegueProgramatically[1]
This has 1 problem tho. The button being clicked to activate my segues is located in the detail view. So the detail view segues back no problem. The Master view however does not segue i'm stuck on how to get that working the same way.
The other option i figured i could do is do a normal segue and than use a custom transition animation but that seems like more of a "hack". So i was wondering if i could segue my TVC back through the detail view.
I hope i'm being clear on how i'm setup and where i need to go.
Cheers,
There is a note in Matt Neuburg's iOS7 book that in some situations you need to subclass UISplitViewController, and put the unwind method in the subclass. You might try that (but be sure to remove it from the detail controller, since only the first one in the chain is called.)
I'm working on a storyboard-based iPhone app.
I am successfully using unwind segues to navigate my stack of view controllers.
However, when I present a modal view controller I cannot seem to be able to trigger the unwind segue that I have specified in the storyboard file.
Is this normal or a bug?
Problem solved.
Apparently I've hit some glitch with the storyboard editor.
What I did was to delete the destination (modal) view controller and then re-create it.
Works fine, now.
Bug report filed.
So I have the same problem (more than two years later!). I haven't fixed the underlying issue, but I found that a modal view being presented with a default presentation style will unwind OK, but one that uses a page sheet presentation style simply doesn't work. The unwindToViewX method gets called on the parent view controller that the unwind segue is moving to, though, so I've circumvented the issue with the following code:
if (self.presentedViewController) {
[self dismissViewControllerAnimated:YES completion:NULL];
}
This saves me from setting up a delegate system as the unwind action is doing all the heavy lifting, but also avoids an issue where perhaps the unwind action might work one day, because in that case self.presentedViewController should return NO because the unwind action worked correctly and we won't end up dismissing two view controllers by accident.
I hope this helps others in the same boat, but I'd also like to hear if anyone else has better solutions.
I created a storyboard for my app which contains the following:
Initial view controller on my storyboard is a Tab Bar Controller (let's call it myTabCtrlr)
myTabCtrlr has forward segues pointing to several other controllers:
a. First segue points to a custom UIViewController (let's call it vc1) on which I create an interactive UIView (let's call it popview1) which is initially hidden. There's a button (let's call it showPopView1) on vc1's view which when clicked would show popview1
b. Second segue points to a navigation controller, which embeds a view controller with 3 buttons, each pointing to an (end) controller.
c. Third segue points to another navigation controller with a similar setup as (b)
On several of these (end) controllers, there's a button similar to vc1's showPopView1 that when tapped, I'd like to switch back to vc1 and programmatically bring up popview1, which I'm doing as follows (but it's not working):
myTabCtrlr.selectedIndex = 0;
//I get a handle to vc1 then
vc1.popview1.hidden = NO;
When I do that, it goes back to the first tab and shows vc1 view (which is good) but it does not show popview1. I tried many different ways to do it but no luck.
Note that if I'm actually on vc1 and I tap the showPopView1 button, then popview1 comes up normally.
Does anybody know why that is the case? This only started after I transitioned to using storyboard. thanks.
After spending hours looking at various ways to solve this problem, and focusing on reverse segues and similar methods, I was able to solve it using a totally different method.. I wanted to share this with others so nobody has to waste so much of their time (although I noticed slow response to my post. Maybe I didn't make the subject attractive enough :)..
It's a really simple solution, but quite effective. I used a Singleton pattern object. When coming from the rest of the tabs, I set a flag in the singleton that vc1 checks in its viewWillAppear method, shows popview1, and immediately resets the flag.. works like a charm!