This might be more of an xcode problem though I'm hoping someone might know someway to help.
I have a VC A that push's to VC B.
In VC A I have defined - (IBAction)doneUnWindingFromBToA :(UIStoryboardSegue *)segue {}
In VC C I defined - (IBAction)doneUnWindingFromBToC :(UIStoryboardSegue *)segue {}
When I drag a UIButton to the Exit button I only see doneUnWindingFromBToC - even though, that push segue has been deleted in the storyboard.
Currently, there is only one segue (push, from A to B) leading into B.
I have also tried to manually create a segue - dragging the scene's view controller icon to its exit icon.
How do I reset the dropdown?
UPDATE:
I commented out the code in VC C and now VC B doesnt let me ctrl drag into the Exit icon.
Its a bug. I'll file a report soon.
I solved it by creating another action method just like the first one (added one extra character) and now it works.
Related
I can't find an answer to this seemingly basic question. Let's say I have a storyboard with two view controllers A and B and a segue transition from one to another. Now, I created a different view controller C and now would like to redirect the existing segue from A to C.
I Ctrl dragged it, command dragged it, etc. it does not seem to work. In the real app, I have way too many segues to try to re-create them from scratch. Is there an easier way?
This question is not a duplicate as flagged since I'm trying to reuse existing segue, not direct to a different controller.
Thanks!
Option 1,using XML file
First,right click the Storyboard file.Then select open as Source
Code
Search segue,then change the destination id
<segue destination="Esd-4c-JQq" kind="show" id="Jnu-RW-1O5"/>
Option 2,using Interface Builder
First, selected the segue source ViewController
Second,Create a same segue(Control+drag),like picture shows
Now,you have two same segue,
You just need to delete the old one
You can drag segue from ViewController icon at the top of ViewController to other Controllers.
Just give identifier to segue by clicking segue pointer on storyboard and then opening attribute inspector and finally you have to do just that code.
Case 1: Push Segue to B from A
[self performSegueWithIdentifier:#"PushB" sender:self]; //PushB is segue identifier
Case 2: Push Segue to C from A
[self performSegueWithIdentifier:#"PushC" sender:self];
Note : You must have Navigation Controller as initial point of storyboard before performing performSegueWithIdentifier.
Hope this will help.
Delete the previous one from A to B and then recreate new one from A to C.
Hope it helps.
I asked a related question that I realized was way over-complicated, so I made some design decicions and have simplified what I need to do here. I am using Xcode 5 and designing for iOS 7.
I have a navigation controller, a main menu (menuViewController) with a button, and a calculator (calculatorViewController) that is arrived at when the button on the main menu is clicked.
My Xcode storyboard is set up like this and it works perfectly (not an image, but I think this should be clear):
navigation controller -----> menuViewController ------> calculatorViewController
I would like to set up my main menu to have 3 buttons, each going to one of the following:
2 separate independent calculatorViewController units
1 other unrelated view
Because of the additional unrelated view, and because I don't think it makes sense for a few other design and content reasons, I do not want to use a UITable Master / Detail setup.
My question is how I might create a "duplicate" of my view and its code that can link to a second button on the main menu and run independently of the first. I know how to link the button from the main menu to the second instance of the view, but not how to create the second instance in the first place.
Of course, I want to conserve on memory, amount of code, and use best practices.
Any help would be greatly appreciated. Thanks in advance!
EDIT: It looks like this is unclear. I'm trying to figure out how to make it moreso.
Menu Buttons
button 1 ----> goes to calculator 1
button 2 ----> goes to calculator 2 (a second, identical, independent version of calculator 1)
button 3 ----> goes to another unrelated view
I know how to make the buttons get to the views. I am trying to figure out what the best way is to create the second calculator. Also, I want to make it clear that both of these calculators need to be able to run at the same time, and so both need to stay on the stack.
Thanks.
EDIT: Thanks for bearing with me.
Here is my code declaring the properties in my destination VC .h file:
// Properties for segue identifiers
#property(nonatomic, readonly) NSString *tankCalcOne;
#property(nonatomic, readonly) NSString *tankCalcTwo;
Here is the code in the .m file for my menu / source VC:
// This allows the view for tankCalcOne or Two depending on which button is clicked in the menu
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:#"tankCalcOne"])
{
[[segue destinationViewController] TankCalculatorViewController:self];
}
else ([segue.identifier isEqualToString:#"tankCalcTwo"]);
{
[[segue destinationViewController] TankCalculatorViewController:self];
}
}
I am getting 'No known instance instance method for selector TankCalculatorViewController' errors in both halves of my if/else statement. I can see why, since I haven't declared them, although I am not sure where I should declare them, as TankCalculatorViewController is the name of the view itself.
I don't think you need a second instance. You do not have to use the push segue. If you use the push segue, it will automatically carry the navigationController. Use another segue or a custom one..
I'll try explain how I would do this.
Create all needed segues and views/scenes in your storyboard (only one calculator scene with two segues leading to it)
Set different identifiers to your segues. This is important.
Create source code for your viewcontrollers and assign them to your storyboard's scenes (again only one calculator view controller with a property for you to specify mode)
In your menuViewController setup your - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender method. Check segue.identifier in order to know which segue exactly is this (you set those in step 2). There in segue.destinationViewController variable you will get already created your target view controller so you can set calculatorViewController.useSecondVariant or whatever property you choose to use in order for your calculator to know its working mode.
I have a problem in iOS7 where I am calling a segue with performSegueWithIdentifier (I have code just like this that works just about everywhere else), then I log the segue in prepareForSegue, then I log again the view controller (VC) that the segue is supposed to push to the top.
prepareForSegue gets called appropriately and the segue has the correct string as its identifier property. Yet the VC that it is supposed to push to the top never gets initialized nor viewWillAppear gets called.
The segue I am talking about, which is the only one that does not work (all the other ones work in both ios6 and 7), is the one leading form the center VC to the right VC. By the way, this works flawlessly in iOS6.
What could be the cause?
the code:
-(IBAction)gotoMainMenu:(id)sender{
DLog(#"DifferentName");
[self performSegueWithIdentifier:#"DifferentName" sender:self];
}
Get in the habit of not wiring up segue's to buttons. Wire them up to the VC and then in the touchUpInside action, fire off the performSegueWithIdentifier.
I had the same issue and solved it as follows. In view A I had a segue that was triggered by a button (UIButton) and the button was also connected to an action in my controller. When I clicked the button in View A, View B would appear as expected. However, when I tried clicking a button in View B to go to View C nothing happened just as you described above.
In my case the issue was resolved in View A. I removed the segue that was tied to the button and let the IBAction that was associated with the button handle calling the performSegueWithIdentifier, then I created a new manual segue that was only tied to the view and voila things worked as expected again.
In short, I guess make sure you don't have both and action and a segue linked to the same button. Hope this helps.
I'm having a weird issue with a navigation controller's back button animation:
my app has a tab bar control with 3 tabs, one of them has a navigation controller with two subsequent view controllers, the first one just show a master table and the second one details, the problem comes when I tap the back button from the detail view controller, instead of slide back to the master view controller it just pops the view without animation.
I've noticed that if I first go to another tab, and then return again to this one, the animation will trigger normally.
I've rebuilt the whole app navigation from scratch but the problem still persist, any help is appreciated.
Thanks in advance!.
Edit: More info added
This is how my storyboard looks like in that particular branch:
Here's the prepareForSegue from "Partidos Activos" view controller:
#pragma mark - Segues
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:#"PartidosEnDia"]) {
PartidosActivosEnFecha *paf = segue.destinationViewController;
CalendarCell *senderCell = (CalendarCell *)sender;
paf.datos = senderCell.dataDic;
}
}
Both viewController viewDidLoad methods are calling super at the start of the method.
As I told before, if I just tap on other tab and then come back to this one, the slide back animation from "Partidos Activos En Fecha" viewController works as expected, it's only when I start the application and go directly to this viewController when the slide back animation doesn't work, and it just gets to the caller viewController without animation.
Hope I added enough info, if not just tell me and I will add it again.
I finally found where the problem was, I was missing a call to super in the viewDidAppear method but in UITabBarController!, I was checking only viewControllers for the tabs but not the tabbarviewcontroller. #rdelmar was right.
I had the exact same problem. The cause for me was an empty viewDidAppear:animated method in my UITabBarController. Once I deleted that method, the animation worked normally again.
I think this it's what you want. If I understand, your problem is handle the stack of the navigation controller right? So, check that link.
I have looked for this problem everywhere.
I know how the unwind scene works. I have implemented the following code in the A VC
-(IBAction)returned:(UIStoryboardSegue *)segue {
try.text = #"Returned from Scene 1";
}
But when I go to my B VC(Which is the VC I want to go back to A VC from) and ctrl drag a button onto the exit at the bottom it will not allow me to. And no function pops up in the exits option. Anyone else had this issue or can help?
To set up an unwind segue, you should
Set up your two scenes with the standard modal or push segue between them:
Define the custom classes for those two scenes to be your respective view controllers.
Implement the action in the .m for view controller A:
- (IBAction)unwindToA:(UIStoryboardSegue *)segue
{
//returning to A
}
Then you can create a segue in B by control-dragging (or right-click-dragging) from some control down to the exit outlet in the bar below scene B:
And if everything above is configured correctly, you will now see your unwind segue listed in a popover:
To make Exit outlet active, add this code to viewController. Now you should be able to ctrl-drag to exit outlet.
It is actually quite odd, that there should be empty method to make it work.
swift
#IBAction func unwindSegue(unwindSegue:UIStoryboardSegue)
objC
- (IBAction)unwindSegue:(UIStoryboardSegue *)sender;
I also had a problem with this even though everything was set up correctly. Eventually I tried closing the project and reopening it and that did the trick. Must have been some bug in Xcode.
This doesn't seem to have been the cause of your problem but I thought I'd add the answer in case someone else has the same problem.
#LoPoBo, #hozefam, & #Van Du Tran
If closing down isn't working, perhaps you were dragging in the wrong manner. Instead of clicking on the Bar Button Item and dragging from Action Segue to the exit try just right click -> hold & drag to exit segue. This was messing with me for a good 20min before I figured it out. Hope this helps someone else too. Using xcode 6.1