In my app, I use a SWRevealViewController for the side menu, and I have it set up correctly. My problem is that from a view controller that has a side menu, I have a segue to go to another view controllers that doesn't use SWRevealViewController. Then on action go back to the SWRevealViewController. (a details Viewcontroller). For some reason the menu button stops displaying the menu.
Related
I have been trying to properly setup a navigation bar in one of my View Controllers for an hour now and have not found any working solutions.
I control-clicked on a button on my app's initial view controller(1st VC) and dragged to another view controller(2nd VC) and selected "modal" as the action segue.
I then added a navigation bar item to my 2nd view controller.
When I run my app on my iPhone, I can tap on the button on my app's initial screen and it will take me to my 2nd VC, and the 2nd VC does display the navigation bar, but the navigation bar does not have the default iOS 7 back arrow to let me go back to the app's initial VC.
I was under the impression that this could be setup exactly like I did above and that the back button functionality would be included by default.
Am I completely lost? Do I need to further customize navigation bar programmatically or with a tick box in the attributes inspector? Is "modal" the wrong action segue option?
I basically just want to have navigation bars at the top of a couple of my VC's so that the user can easily get back to the app's initial screen.
Thanks for the help.
Since you are presenting your second screen (2nd VC) as MODAL from your first screen (1st VC), you will not see the back arrow button on navigation bar. Your understanding about back button works for Navigation view controllers (push segue). For MODAL you need to put a cancel button on second VC's Nav bar and put a dismiss action for that.
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.
Okay, so I want to be able to have a TabBar Controller with two Tabs (like the template in Xcode), but inside the Second tab, I want to have a button that takes the view to a Third View Controller. I want the Third View Controller to have a back button to the Second Tab, I don't want the Third View to retain the TabBar, but when I go back to the Second Tab I want the TabBar to return.
So this is what I actually did, and it doesn't work. I put a button in 2nd view and 3rd view, and I control clicked and dragged to the respective views, and clicked modal. Everything works, except when I go back to the 2nd view I lose the tab bar.
Pictures of what I am talking about:
Screen Shot of Xcode:
Screen Shot of iOS on 2nd view:
Screen Shot of after I click button to go to third view:
Screen Shot of after I Click button to go back to second view. ( lose tab bar !)
http://s13.postimage.org/78gqghflj/Screen_Shot_2012_07_09_at_2_03_41_PM.png
http://s16.postimage.org/gdwus4w6t/i_OS_Simulator_Screen_shot_Jul_9_2012_2_02_50_PM.png
http://s10.postimage.org/5uq3ste7d/i_OS_Simulator_Screen_shot_Jul_9_2012_2_02_57_PM.png
http://s8.postimage.org/gpmsx959x/i_OS_Simulator_Screen_shot_Jul_9_2012_2_03_54_PM.png
You don't need a separate modal Segue back to the Second View Controller, you can just dismiss the modal view controller when "Back to Second View" is clicked
[self dismissModalViewControllerAnimated:YES];
I have a navigation bar controller + tab bar controller + UITableview for the first view of my app and within there, everything is fine. But when i click one of the table cells, i do a pushViewController with the navigationcontroller and it shows a view controller (the tab bar and navigation bar still show of course). but only within this view, i need to click about 60 px above my target to trigger the click event. Even for the navigation bar "Back" button, I need to click the very top of the iphone screen to go back.
Has anybody experienced this before!? i have no idea what is wrong
I think this happens when you put buttons directly on a window. I'll stick to keeping everything on views
I have a root view controller with just a simple navigation button that loads a questionview. When I use pushViewController a back button appears. Instead I want a custom button in the top right of the uinavigationcontroller and I want to remove the back button after the page transition.
how can i achieve this..
Take a look at UINavigationItem. You can accomplish both your goals by properly configuring your view controller's navigation item. Use the -setHidesBackButton:animated: to hide the back button, and the -setRightBarButtonItem:animated: to add your custom button on the right side of the navigation bar.