Using a navigation controller within a view controller - objective-c

I am new to iPhone development. I have created a window based application in which I use navigation controller for switching from one screen to another.
On one screen I use a viewcontroller for switching to another screen. However, I then need a navigation controller in this screen for switching between screens. But I am unable to switch from one to another.
How can I use a navigation controller in this screen, when the previous screen is switched from a viewcontroller?

You're not supposed to use nested navigation controllers. You should just keep pushing view controllers to your main navigation controller. You can always access that navigation controller through self.navigationController in your view controllers.

You can use a navigation controller to hold your first view also. Just set the navigationBarHidden to YES, and toggle it when you push your second view controller.

Related

Embedding navigation controllers in a tabbarcontroller that is not the root view

I’m having some trouble with a integrating a navigation controller inside a tabbarcontroller that is not in the root view. My issue is that the root view, which leads to the tabbarcontroller is embedded in a navigation controller. Naturally, since the root view leads to the tabbarcontroller then each tab uses that root view’s navigation controller. Ideally I’d like to wrap each tab in its own navigation controller so that I could adjust them accordingly. I’ve tried using a modal segue and it allows me to put each tab in its own navigation controller, but this implementation does not work due to a sliding side menu plugin I am using. Embedding a navigationcontroller in each tab causes my autosizing to think there are two navbbars (because there are.) Any ideas? Is there a way I can maybe remove the navigationcontroller from latter views and keep it on the root?
TabBarControllers are meant to be root controllers, so your best course of action is likely going to be restructuring the navigation of your app to fit this paradigm. If you don't want the TabBarController to be the first view that the user sees (for instance, if your app has a login screen) then you can just modally present the login view controller over the top of the TabBarController when the app starts up (if needed).
Barring that, if you're just looking for a quick fix for your double navigation bar issue, you just want to get around your double navigation bar issue, you could just set the Top Bar property for your NavigationController to "none", as shown below.

Creating an View without the navigation Item bar in Xcode

I am trying to connect a new empty View(homeScreen) from a ViewController (loginScreen) using Xcode 6 Beta 4 and Swift. A button triggers the segue to the homeScreen View. The problem is that when I add the segue, my blank/empty homeScreen View magically gets a Navigation Item Bar on top of the view.
You can see that without the segue my homeScreen View its empty:
After the segue it looks like this:
As you can see, Xcode inserts the Navigation Item Bar on top (grey rectangle). I would like to know how to get rid of it or how to create an empty View that remains empty even after assigning a segue to it.
Thank you so much for your help!
Cheers!
UPDATE: My goal is to create a navigation bar kind of like the one Facebook implements in its' iOS app. On top have the search bar and maybe some more icons. Does anybody know how to do that? I tried to hide the Navigation bar by selecting my view controller and in the Attributes inspector setting the "Top Bar" attribute to none, but it does not work. Any suggestions?
Thanks again.
Does loginScreen is inside a UINavigationController? If it is, the new showed view controller (homeScreen) is supposed to be in the navigation controller too, and thus it has a navigation bar by default.
You can hide it if you want, but then you have to find an alternative way to navigate in your navigation controller.
Otherwise you can present the homeScreen modally changing the type of segue to "Present Modally".
For more details on view controller presentation see this document plus some updates in iOS8 (WWDC session: View Controller Advancement in iOS8).
EDIT: To implement the FB-like navigation bar I would customize the UINavigationController bar:
read this AppCoda tutorial about customizing the bar
to add a search bar use the code like:
let searchBar = UISearchBar()
...
self.navigationItem.titleView = self.searchBar
This is because the segue is a "push" segue ("Show (e.g. push)") from a View controller that is already included in a Navigation controller. Therefore, it is put in the stack of views of this Navigation Controller, and therefore receives a navigation bar.
If you don't want a navigation bar, then use either a modal segue ("Present modally"), or a custom segue.
Same thing if you need a different navigation Bar (not linked to the first Navigation Controller). You can perfectly have a modal segue leading to a UIViewController, which is embedded in its OWN navigation controller (or having only a navigation bar). Have a look in the menu: "Edit / Embed / Navigation controller".

UINavigationController hiding navbar with custom transition delegate in iOS7

I have a UINavigationViewController with two view controllers. The root view controller needs the navigation bar to be hidden, while in the second view controller, the navbar is visible.
I implemented custom transitions with UIViewControllerAnimatedTransitioning
When I push the second view, everything is fine. However, when I pop the view and return to root, there's a jump in the root controller frame. It animates in as though it has a navigation bar and when the animation completes, the frame is re-adjusted to full-screen.
What's the proper way to do this? The default transitions don't display this problem.
Two simple ways to fix it:
Hide the navigation bar entirely from the navigation controller and add a custom navigation bar to the first screen, independent on the navigation controller.
Let only the first screen to be in a navigation controller and create a custom transition to the second screen, not using navigation controller's push but implementing the push animation by yourself.

UIStoryBoard Navigation Controller disappearing after segue

Reference layout via storyboard:
http://i.imgur.com/M7AmdP2.png
Reference landing page:
http://i.imgur.com/Y3g45uy.png
I am trying to use the bottom bar as displayed in picture 2 to control my app. When I select my option on the first page (Such as the songs tab), but when I go to the next page my navigation bar at the bottom disappears. I am using segues to direct my applications view flow.
I have tried making various controllers subclassed to a UITabBarController & pushing as modal. Neither of those kept the navigation controller
You shouldn't have that navigation controller as the initial controller, the tab bar controller should be first. Then, in each of the three tabs, the root view controller should be a navigation controller, followed by the ones you show in your image.

iPhone Navigation Controller Back Button?

I want to add a Back button to a Navigation Controller. This is how my storyboard looks like:
I have a ProgViewController for the main screen. The TableView is embedded into the Navigation Controller. I also have a ProgPlayersViewController for the TableView.
My question is how can I add a Back button to the Navigation Controller?
Thanks for your help.
ProgViewController needs to be in the navigation stack so that you can go back (ie. 'pop') to that view controller.
The actual button itself is created by the navigation controller assuming that there is a view controller to actually go back to.
The navigation controller, as you have it in your diagram, needs to be before the ProgViewController and not after it.
Note if you don't want the navigation bar to be visible in the ProgViewController you can set it to hidden.