Navigation bar object in xcode 5 not showing back button and has no functionality - iphone

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.

Related

Navigation between view controllers

On my application, I have four view controllers (VC):
HOME
MESSAGES
PROFIL
SETTINGS
On each VC, an opaque bar bottom with four bar button items for each VC (home, messages, profil, settings).
When I tap on one bar button item, I manage the navigation with a segue (show) and it loads the selected VC.
I would like to find a way to not load again a VC already loaded one time.
For example:
The app is launched
HOME VC is loaded and appears
User taps on PROFIL
PROFIL VC is loaded and appears
User taps on HOME
HOME VC appears without calling viewDidLoad method, because it has already been loaded four steps ago
I tried with all types of segues (show, present modally, etc.) and with presentViewController method, but each time the viewDidLoad method is called.
Is there an easy way to do this or do I have to manage this with a boolean to indicate that the view was already loaded?
I would like a menu like WhatsApp application has for example.
WhatsApp uses a Tab Bar at the bottom. Are you using Toolbar? ViewDidLoad only executes once per view unless you unload the view from memory.
The easiest way to adapt your app is to just add a Tab Bar Controller in your app and then delete the 2 automatically added view controllers and set a relationship (just like a segue; it's below segue types) between each view controller and the tab bar controller. To change the icons, modify them in the Tab Bar Controller View. Then segues will work automagically just like in WhatsApp. :)

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

Tab bar disappears after touching cell in tableview

I have an issue with a tab bar app. I am making a tab bar app with three bars on the bottom. On my my first bar it is a tableviewcontroller. When i ckick on the table view controller it takes me to a different view (which doesn't have the tab bar). When I clicked back to the home screen (which has the tab) the tab bar is gone.If you need a picture i will post it!
You may have set your UITableViewController segue to a modal style. If this is the case, you should change it to a push style.
In order for a push to work, your view controller needs to be in a UINavigationController. In your story board, select your root view controller and embed it into a Navigation Controller like this...

Modal flip in tab bar tab, only the view, storyboarding

I have a tab bar with five tabs.
In one tab I have a mapview. I have an info button in the bottom right hand corner of the map. When a user clicks the info button, I want the mapview to flip to a view that has information about the mapview. I'd like a back button in the nav bar to flip back.
How can I do that?
I've managed to create a view controller and make a modal segue, but it doesn't keep the tab bar with it. Worse still, I created a back button on the flipside-viewcontroller with a modal segue back to the mapviewcontroller, and when you go back, the tabbar is gone!
I'm using a storyboard, and most tutorials I find use nibs and xibs. The more control-clicking I can do through the storyboard-IB and the less code the better. Any help is appreciated!
Once you have created in the backButton in the MapInformation view in storyboard, you can add the following to your MapInformation.h/m:
MapInformation.h:
-(IBAction)backButton:(id)sender;
MapInformation.m:
-(IBAction)backButton:(id)sender
{
[self.presentingViewController dismissModalViewControllerAnimated:YES];
}
After that, make sure to connect your IBAction in your storyboard(control-clicking).

Invisible back button when view controller pushed onto navigation controller

I'm using a navigation controller to drill into a detail view when a cell is tapped. When I push my view controller onto the navigation controllers stack, I expect to see a back button that I can tap to pop the previous view off the stack.
The issue is that the back button isn't visible, but when tapping where it should be returns me to the previous view. What's the problem?
Ensure you have set a title for the master view - for example in viewDidLoad add this -
self.title = #"The Title";
Weirdly, if there is no title for the parent view controller on the stack, rather than show an empty back button, the iPhone will not display a button but will allow taps on the area where it should be.
This bugged me for a long time!
At least as of iPhone 3.0, you can also avoid the dreaded invisible back button by setting a title on the root controller's navigation item in your main window's nib (MainWindow.xib in wizard-generated projects).
Lets see if this helps you.
I had the same issue where I used a navigation based application and set up my search, rotation etc..
BUT, when I clicked on the table cell I was directed to the next view but that view did not have a back button present.
I tried to add a title to the back button but that did not work so this is what I did.
I opened the mainWindow.xib file and added a Bar Button Item to the group of other items inisde the window (where the file's owner is located). I then assigned an image to the button (you can add text here if you want).
Then I clicked on the Navigation Item and hit command 2 to open up the Navigation item connections
and chose the back bar button item and dragged it to the bar button item I wanted to use for my back button. And there you have it.