I have a view which is located inside a navigation controller which is inside a tab bar controller like this:
Tab Bar Controller
Navigation Controller
View Controller
I have designed the layout of the View Controller in a xib. When I click the tab for the view the view is displayed correct. The view will be place within the navigation bar and the tab bar - it will not overflow.
But when I want to open the view programmatically - not via the tab bar - but with pushViewController [1] the view expands all the way to the outer bounds of the frame. The view will be over the status bar and below the tab bar.
I cannot find a solution to this. Does anybody have any ideas how to solve this?
[1]
[self.navigationController pushViewController:[[MyViewController alloc]
initWithStringAddress:"someIdUsedInController" animated:YES];
Related
I'm trying to display the navigation bar at the top of the screen, but it's not showing in embed navigation controller.
Here is how it is in the storyboard:
And here it's in the simulator:
As you can see, I created a custom TabBar (following this tutorial) at the bottom of the screen so I can navigate between the different views.
I believe that I'm going to have to load the navbar programatically because the only solution that I found was to set the navigation controller as the initial view controller, but I already set another view as the initial one so I can't do that.
Issue :
When you instantiate a viewController using storyBoard identifier they wont come with free embedded navigation controller, even if you have added a NavigationController to them. As a result you are adding a viewController without navigation bar to your tab bar VC.
Solutions:
Solution1: If you want each child viewControllers to carry their own navigation controller hence their own navigation stack, provide a storyboard identifier to Navigation Controller behind your child viewControllers and instantiate the Navigation controller itself rather than ViewController. And add NavigationController as you tab bar looking VC's child. Because navigation controller loads the embdedded VC by default you will see your child VC with nav bar.
Solution2: All that you care for is only nav bar than add the Navigation Controller behind the VC containing tab bar looking View.
Hope it helps
Have you tried constraining the navigation bar to your view? Otherwise it can move offscreen.
You need to point the tab bar controller segue to the navigation controller of your view - otherwise if you point the segue straight to the view you're just loading the view without any navigation controller attached.
I have a Tab Bar application coded in Objective-c. One of the tabviews I have is a TableView. What I'm trying to do is, when a cell of this TableView is selected, the app takes the user to another view, but this view isn't on the tab menu, and I don't want to lose the tab menu when this view appears.
Is it possible to do it? How? Couldn't find much on the web.
Just embed navigation controller to that tab's viewcontroller which have tableview.
so your viewhierarchy should be like tabbar controller - navigation controller - viewcontroller (tab) - detailviewcontroller
you can embed navigation controller by selecting viewcontroller, then from menu select editor then embed in then navigation controller.
Hope this will help :)
If you are having the single View Controller to show then you can try doing this by adding the new view controller's view as
subView to the current view controller's view
Eg:
newVC.view.frame = self.view.frame;
newVC.view.frame.size.height = self.view.frame.size.height - HEIGHT_OF_TAB_BAR;
[self.view addSubview:newVC.view];
If there are more View Controller's that are adding further then
using the navigation controller under tab bar controller will also
work.
Refer: How to implement tab bar controller with navigation controller in right way
Does anybody know what kind of view controller this app uses? I am trying to implement one somewhat like this but can not get the tab bar to appear at the bottom when I use the table view controller. I also can not get the title of the view to appear at the top where it says home.
I would say this is a tab bar controller. The home tab you show may just have a navigation bar placed on top of it as a sub view or it is embedded into a navigation controller.
My image shows a tab bar controller as the root controller and initial controller and the view from the first tab embedded in a navigation controller.
Hope this helps!
The screen you are looking at is a combination of a UItabBarController a UINavigationController and a UITableViewController.
I am trying to setup a Model View Controller to have a Navigation Bar just in the storyboard.
I have setup a segue from one view controller to another and marked it as Model.
I have changed the Model VC to have Top Bar : Translucent Navigation Bar.
I call the segue by name with the following:
[self performSegueWithIdentifier:#"testModel" sender:self];
When the model view controller shows up there is no Navigation Bar. Am I missing something that should make this show.
The Model View Controller is not actually in a Navigation Controller stack and shouldn't be as there is no movement other than dismiss from this Model View Controller. I am just trying to use the Navigation Bar to show a title for the model VC.
When you changed your view controller to "Top Bar : Translucent Navigation Bar.", that is under "Simulated Metrics". Changing that value tells Xcode that the view controller will have a navigation bar, it does not actually create a navigation bar. I suggest you either
Embed your view controller in a navigation controller (there is no rule that says you have to push anything from your navigation controller, and you might decide to add features in the future)
Use a toolbar instead of a navigation bar
Just use a label if all you want is a title on your view controller.
My app has two distincts modes. There's a tab bar controller in the app delegate. There are two tabs, both using subclassed view controllers. The two view controllers essentially contain a nav controller each. The nav controllers have their root view controller, and normally when changing screens, I just push and pop controllers of the respective nav controller. This has the (normal) effect that the bottom tab bar is always visible, all great and sound.
This one time I'd like to present a screen modally however, so that the user can't do anything else than confirm or cancel the page using two buttons, ie I want to hide also the bottom tab bar. This would be a case for presenting the view modally I thought, but the view is presented within the nav controller bounds it seems, so the bottom tab bar is still visible, and this causes confusion in navigation the app. I'm not sure how it's possible that the modally presented view is not hiding the tab bar. Most of the questions around here seem to have the problem the other way around (wanting to (incorrectly) present a modal view and leave the tab bar visible).
These are my attempts:
[self presentModalViewController:controller animated:YES]; // inside tab bar controller :-(
[self.tabBarController presentModalViewController:controller animated:YES]; // nothing is displayed. The new controller is instantly deallocated.
[self.navigationController presentModalViewController:controller animated:YES]; // inside tab bar controller :-(
Investigating this, the self.tabBarController is actually nil. There seems to be no link back to the tab bar controller... I guess, to display modally on top of the tab bar, I need to get a link to that tab bar controller?
I seem to have found a solution, I'm not sure it's kosher, because somehow I wasn't able to use the self.tabBarController pointer of the view controller in which I start the view controller call.
What I did was reach for the app delegate, the app delegate having the tab bar controller defined as a public property. I could use that tab bar controller property to modally display my view controller over everything on the screen.