iOS 7 - Add a view to a navigation controller and make it the first view to appear - ios

Sorry if my title is a bit confusing and if it is basic but I've been trying to figure it out for quite some time.
I have 4 views already in my story board and they are all in a navigation controller, however, I need to add another view and make that newly added view my first view. I have added my view already, however, whenever I go to Editor -> Embed In -> Navigation Controller, I end up getting a new Navigation Controller.
Is there a way to use my existing Navigation Controller? Or am I forced to use/add a new one?
Sorry if this is a simple problem and I'm missing out on something basic. Thanks for any help.

You need to make "new" viewcontroller rootViewController of your UINavigationController.
Select your NavigationController,
Click and drag from NavigationController while holding your Control key down.
Drop on the new view controller.
Select rootViewController from the popup menu.
Once done, you should be all set.

Related

using my ViewController as a TabBarController

So i currently have a ViewController that has a tableView in it with a tab bar on the bottom. Its basically an instagram clone. However, i built all the tableView functionality and am now just getting around to playing with the tab bar items to segue to new view controllers.
I cant figure out how to attach my already created tab bar(which is inside a regular view controller) to other view controllers in IB.
The ctrl+drag from the newly created view controllers to my MAIN view controller doesn't work. It doesn't provide an option to create a view controller segue.
Below is an image of my current view controller and a brand new one to the right
Any help on how i can do this would be greatly appreciated
On you tabbbar controller ctrl+click and drag to the view controller you want to create a relationship to.
Then when the little menu appears, under 'relationship segue' click 'view controllers'
You should then end up with something like this. Continue the same process to add more relationships.

Tab bar controller is not showing bar button item

I'm new in Objective-C, and even more using storyboards. This being said I'm trying to use a bar button item within UITabBarController and UINavigationController as can you see in the image below.
But once I run the project in simulator this item is not showing. I would appreciate a non programmatically solution if it's posible.
Okay, so the way to do this:
When you create your tab view controller. You have to add a navigation controller that will handle each tab.
Tab View Controller --> navigation controller --> View Controller 1.
Then add the bar button item to view controller 1. Then go ahead and add the segues.
Now, still it won't show up.
But, if you go to your code for your view controller 1: Add a reference from the storyboard of your bar button item into your View Controller 1 file. Then, in ViewWillAppear():
self.tabBarController.navigationItem.rightBarButtonItem = _btnNewContact;
From there, it will show up and the segue you have configured in your storyboard should work perfectly! =)
After I spent a while trying to get the best way to do it I finally did that I should have done since begin. Read official apple documentation.
Parameters
viewController
The view controller that is pushed onto the stack. This object cannot be an instance of tab bar controller and it must not already be on the stack.
In other words, my approach is just a bad design.

How to build navigation controller from existing view controllers drew in storyboard?

I have built some view controllers in storyboard like in the picture below
I already implemented the data inside them, modal segue is used for transitions in between. Now I just realise when I push "back" button, previous view won't be properly loaded. I figure I should switch to navigation controller and add those controllers in stack instead. But I don't know how to go from where I am now.
I think I should make changes programmatically because I found building navigation controller in storyboard won't have much variation in UI design (at least I don't know how to implement existing pages in that way). So what should I do to implement programmatically? Please help me, thanks!
Select Category View Controller and go to menu: Editor > Embed In > Navigation Controller. Then change segues style from Modal to Push.

Proper way to segue between two simple View Controllers in iOS 7

I'm mainly from a C# background, so the workflow for iOS is a bit unusual for me, at least for now.
I was having a problem having simple segue from a main menu, to a another menu/work area, and then with the ability to go back to the main menu.
For a test, apparently I did something wrong.
I didn't write any code for this test to exhibit the problem.
What I did was just,
create a new single-view app
drag an additional view controller onto the work area
drag the start arrow to the new view controller (so it becomes the initial view, same thing as checking the checkbox to set it as the initial view)
added a button to each view controller
Ctrl + clicked and dragged the buttons to the opposing view
for the segue type, I chose "replace"
now the program crashes if I hit the second button to go back to the "main menu" (green view controller in this example)
So what am I doing wrong? Do I need to add some form of delegate or something?
I did find this, though it present fewer segue options in the tutorial than what I have.
https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/SecondTutorial.html
These are the options I have when I Ctrl + Click from a button to another view
-Push
-Modal
-PopOver
-Custom
-Replace
"Have you embedded a navigation controller? You need to go to editor->embed in-> Navigation Controller. You need a navigation controller for push segue. – Kaushal Bisht"
This solved it for me. Now I'm just going to work on replacing the navigation bar with custom UI controls.
Thanks everyone! :)

Trying to add 3rd tab to tabBarController

I'm trying to add a 3rd tab to the tabBarController using ios5. The standard object you get when you drag it out to your storyboard has 2 tabs. Does anyone know how to do this? I searched the internet and all examples start with their tabBarController with the extra tabs without showing how to get it.
Here is the video I watched that taught me how to add a third tab to a TabBarController:
Tab bar for Xcode Swift for iOS
I will summarize the process below.
Create a new Tabbed Application project
This will automatically provide two tabs that already "just work".
Add new View Controller
Drag another view controller onto the storyboard.
Add Tab Bar Item
Drag a Tab Bar Item onto the new View Controller that you just added.
Connect to Tab View Controller
Click and Control-Drag from the Tab View Controller to your new View Controller. A menu will pop up. Choose the view controllers option under the Relationship Segue group.
That's it. You should be able to run it now and have all three tabs work. Watch the video that I linked to for more details.
Note:
To do anything on your new tab, don't forget to add a new View Controller class (as you would for any new View Controller).
Based on Wolvorin and Tom van responses, and based on what I have experienced you should do as following:
Create an empty View Controller (in Controllers and Objects)
From Windows and Bars, drag Tab Bar Item to the newly added view
From the main View Controller, select Tab Bar Controller icon (next to First Responder), and Control-Drag to the newly added View
BOOM you have new tab
To expound on #Roozbeh 's answer, when you control drag from the Tab Bar Controller to the newly added view controller, make sure you select the view controller option under Relationship Seque
I was reading this question after having the same problem and I wanted to clarify what the exact step was.
for third tab first add a view controller and then right click the tabview controller and then from it's storyboard segway from relation controll drag to the added view controller and it's done
Look in the right part of the screen, I believe it's the Objects library view. Just find the "Tab Item" (or something) and drag it into the bar.

Resources