performSegueWithIdentifier isn't working - iphone

I have this code running when I tap a button:
[self performSegueWithIdentifier:#"services" sender:self];
NSLog(#"ButtonClicked");
I can see the log message appearing each time I press the button but the segue isn't activating.
In my storyboard file I have a segue named services, that's the segue I want to activate.
Any idea where I'm going wrong?
Edit
The button is inside a tab bar controller, will that affect things?

For push you need to embed your source view controller in navigation controller.You can do this as follows:
Select your source view controller, Go to Editor and select Embed In
-> Navigation Controller.

Related

SWreveal - how to go back to the view controller I started with

I am using SWReveal. Everything works fine except that I would like to be able to go back to the view controller from which I fired the sidebar.
For example, let's assume I have 2 view controllers: VC1 and VC2.
I'm on VC1. I open the sidebar and select the option to move to VC2. I then want to move back to VC1 but not via the sidebar (imagine that VC2 is a settings page that is applied to a table on VC1 - I do not want to have a button on a tool bar for the odd occasion I am going to use this functionality so I'd rather it lived in a sidebar menu).
If I was not using a sidebar menu, a simple segue from VC1 to VC2 via a button would enable me to use the 'back' button.
Is there a way to achieve this kind of behaviour with SWReveal sidebar menu?
I faced the same issue on my application first i add a segue to the main menu of type modal with identifier then in the prepare for segue i put that code
if ([[segue identifier] isEqualToString:#"backtologin"]) {
MWViewController *controller = (MWViewController *)segue.destinationViewController;
}

Tab Bar mysteriously disappears?

Attached are two images. The first shows my current main.storyboard, and the second shows my problem when I run the app. I have a tab bar controller that has two tabs. On the first tab there is a button. When pressed, the button goes to another view controller with content. At the top is a Navigation bar with a back button. After viewing content, I press the back button, and am back on the original page with the button, but the tab bar is missing. I have seen a few answered questions, but it appears they made their tab bar in the view controller instead of the storyboard. Another says that I should never return to a previous view unless I use an unwind segue. Is this true? If so, how do I set up an unwind segue. If not, how do I fix this problem otherwise? Thank you.
http://i.stack.imgur.com/IYmX2.png
http://i.stack.imgur.com/7slt5.png
The problem is in the wiring of your ViewControllers. You have probably embedded your UITabBarController inside the UINavigationController and not the other way around.
A correct layout looks like this in Interface Builder :
To reproduce:
In Interface Builder drop a UITabBarController. This will come with 2 UIViewController's already wired in.
Pick one of the UIViewController's (let's call it VController1) and click on Editor / Embed in / Navigation Controller. This wires the VController1 to live inside a UINavigationController that is inside the UITabBarController
Add a 3rd UIViewController next to VController1 Let's call it VController3
Wire in a segue between VController1 and VController3, for example with a button.
I hope that's clear enough
Try Linking the button in your viewcontroller (other than the views of the tabbed bar controller) with the tabbed bar controller. Create a segue that links the button with the controller of the tabbed bar application

Why a bar button item on a NavigationViewController won't trigger an IBAction

I have a pretty basic app I am working on that uses a navigation view controller system. One of my view is a table view that I added a bar button to in the story board. This bar button is just a basic add button for adding a new item to the table view. I identified the segue for use in my prepare for segue method and then I created an IBAction for the button as well.
The segue pushes to my next view just fine and passed my desired object, but the action never triggered. I ended up having to put the code for the IBAction in my prepare for segue method to get it to work.
I'm just wondering why IBAction was never triggered.
1) remove the segueNamedFoo you have created from the button to the destination view controller
2) create a manual segueNamedFoo push segue by CTRL-dragging from the leftmost small icon at the base of the origin view controller to the destination view controller
3) in your - (IBAction)doStuffBeforeSegue:(id)sender method which you have connected to your button perform the tasks which you want and then call [self performSegueWithIdentifier:#"segueNamedFoo"]

Change view controller on press button

I have two View Controllers, I need to have a button in ViewControllerOne that when I press it Show me ViewControllerTwo.
In storyboard I related both views with a "Presenting Segues" - Push modal. And both views have a view controller class.
I'm not sure what you mean by "I related both views with a 'Presenting Segues' - Push modal." Are you using a navigation controller and want a push segue, or do you want to do a modal segue? A "push modal" is a contradiction in terms.
So, let's imagine that you want a modal segue. So, you put a button on the first view, right-click and drag (or control-click and drag) from that button to the second view.
You'll get a pop up asking for type of segue. Select "modal".
And you're done transitioning from 1 to 2. No code necessary.
If you want a button on the second view to take you back to the first view, you do not want a modal segue from the second view back to the first view, but rather you want to dismissViewControllerAnimated. You can do this via a custom segue, or easier, just have a button which calls dismissViewControllerAnimated. Thus, you'd add a button to the second view, and while the editor is in in "assistant" mode (where the associated .h file is showing below the interface builder; see below if you want to know how to show the .h file at the same time as the Interface Builder screen), right-click (or control-click) and drag from the button on the second view down to the second view controller's .h file:
By the way, if you don't see the .h file there, click on the "assistant" editor button and choose "automatic" for the files to be shown down there, and you should be good:
It will then show you a pop up asking you what you want to do. Select IBAction and give your new method a name:
Then go to your code for the view controller, and add the dismissViewControllerAnimated code:
All that code says (and in this example, I just called my IBAction dismissTwo) is:
- (IBAction)dismissTwo:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
If you want to do a push segue, it's even easier. First, if you don't already have a navigation controller, add one by selecting the first view and choose "Embed in" - "Navigation Controller":
When you do this, you'll have a new navigation controller (which you don't really need to do much with) and the first view will have a navigation bar.
Now, right-click (or control-click) on your first view's button and drag over to the second view:
This time, select the "push" segue:
And you'll know that it worked, because your second view will have a navigation controller
You don't need a button to go back, because the navigation controller will automatically have a "Back" button, so you don't need to add your own.
This is how you achieve a push segue.

get rid of navigation bar in view controller iphone sdk

I am basically creating an app that looks like a power point presentation. every time the user clicks on a button I add another view controller. So here is what I have:
This is the ViewController that I want to add when the user want's to go to the next slide:
I have a button that when clicked it shows this view controller. In this example it will show nothing because the view controller is empty.
so when that code get's fired this is what happens with my iPad:
It loads that view controller perfectly fine but with the navigation bar at the top. How could I get rid of that navigation bar? I think the problem is the code because the view controller is empty. I know just the basics of objective-c so I have not been able to fix it with code.
Insert this line of code before presenting your navigation controller modally:
[navControl setNavigationBarHidden:YES];