I have a window with a UITabBarController as rootViewController. The UITabBarController has two children: A UINavigationController and a UISplitViewController (according to the latest docs this should be OK, and it works except for the following problem).
Both the UINavigationController as well as the UISplitViewController show a MyMasterTableViewController which can push instances of MyDetailViewController.
MyDetailViewController has self.hidesBottomBarWhenPushed = YES to make the TabBar disappear on push.
When I push MyDetailViewController onto the UINavigationController the UITabBar disappears as expected. When I show MyDetailViewController on the UISplitViewController while it is collapsed, I would expect the same, since the collapsed UISplitViewController contains only a UINavigationController with the Master which pushes the Detail ViewController. It doesn't however.
How can I let a collapsed UISplitViewController make the UITabBar hide on showing MyDetailViewController like the UINavigationController does?
Unfortunately you cannot take advantage of Hide Bottom Bar on Push while using a UISplitViewController inside a UITabBarController. You can override the UITabBarController viewControllers and for the iPhone only, point to the MasterViewController's UINavigationController in the Storyboard. This is where you can Hide Bottom Bar on Push. The UISplitViewController for some reason does not respect the flag on a push, probably for iPad purposes.enter image description here
Related
I have a UITableViewController was added to a UIPageViewController as the pages, the program push PageViewController and show UINavigationBar on the top of the PageViewController, I want to add UIBarButton to UINavigationBar to control UITableViewCells, but can only do it on the screen of PageViewController, that means, all events related to this button must be handle in PageViewController, because all these events are related to TableView cell controls, I want them are handled in UITableViewController.
I tried many ways, like define a IBOutlet in UITableViewController, and when viewDidLoad, set self.NavigationItem rightitem to this IBOutlet item, all did not work.
I don't know how you're creating the UINavigationController but I assume you're doing it from PageViewController. If that's the case, then make sure that the PageViewController pushes onto the UINavigationController the UITableViewController. You cannot add the UITableViewController to the PageViewController.
In other words, the PageViewController creates a page with a UINavigationController. Then you push onto UINavigationController the UITableViewController.
At that point when inside your subclassed UITableViewController, you should have access to self.navigationItem, etc...
UIViewController has a property called UINavigationItem.
So how can a UIViewController refer to UINavigationBar?
The UINavigationBar is not displayed yet till UIViewController is pushed into a UINavigationController. So it's not available in viewDidLoad.
So how do we customize it?
I added UINavigationBar to the XIB. However, how do I specify that I want to use THAT UINavigationBar rather than the one provided by UINavigationController?
I added UINavigationBar to the XIB. However, how do I specify that I
want to use THAT UINavigationBar rather than the one provided by
UINavigationController?
You don't. The navigation bar is the nav controller's responsibility -- your view controller doesn't get to swap in its own nav bar. Each view controller has a navigation item that it can set to customize simple things like title and buttons, and you can get the navigation controller's nav bar when the view controller is pushed onto the navigation stack using the controller's navigationController property.
On my firstViewController I have a tabbar that contains my firstViewController and a helpViewController.
When I click on a button from the FirstViewController, I push a NewViewController. But, when this view is pushed, I want to change the content from the TabBarController to display other ViewControllers, like infoViewController, optionViewController and NewViewController. Is that possible?
The First Image represents my application. The FirstViewController has a button that will push the NewViewController. When the user clicks this button, I want that my app shows what is in the second image. Is possible?
Yes, this is possible (I just did a proof of concept in Xcode). Assuming that you are using storyboarding, you need to make your initial view controller a UINavigationController otherwise you won't be able to use the push segues. Then, make the first UITabBarViewController the root view controller of the navigation controller. Put an entirely new UITabBarController into the storyboard, and then put a UIButton into the firstViewController and link it via a push segue to the new (second) UITabBarController.
When you tap the button the old tab bar will slide off, and the new one will slide on.
Here's an example of how it all looks:
!!This app uses navigationController and TabBarController!!
Using the storyboard I saw each piece of the app, then I had the Idea: Insted of pushing the NewViewController, how about push a tabBarController? When the user clicks the button, the app will push the tabBarController with 2 TabController`s.
Just add New File to your project, sub classed UITabBarController. Then add this code to the init method of your tabBarController: self.hidesBottonBarWhenPushed = YES;
On ViewDidLoad just alloc and init what views you want to display on the tabBar and
self setViewControllers:[NSArray arrayWithObjects: vc1, vc2, vc3, nil]];
Working fine here :D
You can nest TabBarControllers. But that would look strange. And the first TabBar wouldn't be changed. Pushing a TabBarController into a TabBarController is not possible because TabBarController does not support pushViewController. Thats only possible with a NavigationController.
Anyhow you can change the content of the TabBar completely programatically.
i have a uitableviewcontroller with uisearchdisplay controller. tapping on table cell pushes another view with some content and hides the navigationbar in the pushed view controller. the view controller has it's own uitoolbar, so far everything ok. the problem is that when a search result is shown and then tapping on the table cell view pushes the viewcontroller with uitoolbar with a navigation bar above it. so two bars on the pushed view. i dont want the navigation bar to be hidden. this code works if the viewcontroller is not pushed from search result
[self.navigationController setNavigationBarHidden:YES animated:YES];
what i'm missing using uisearchdisplay controller and hiding its navigation bar when other view is pushed?
I have redesigned my app. i dont use uisearchdisplay controller. instead i use uisearchbar and tableview which works perfectly.
My view controllers are structured like this:
> UIWindow
> - RootViewController with UIScrollView (2 pages, pagingEnabled)
> -- UINavigationController (in the first page of the scrolling view)
> --- HomePageViewController (plus other ViewControllers pushed on the stack)
> -- MinutiaViewController (second page)
UIScrollView holds the UInavigationController as a subview
[scrollView addSubview:navController.view];
In my scenario I want to:
disable UIScrollView scrolling (scrollEnable=NO) once a new view is pushed onto the UINavigationViewController
enable UIScrollView again (scrollEnable=YES) once the new view is popped and the UINavigationController shows its root again
(HomePageViewController)
I figured out how to disable the scrollView scrolling when pushing a new view.
But cannot figure out how to enable the scrollView scrolling when the new view pops off the stack.
So far I tried
1 triggering viewWillAppear; viewWillDisappear; manually and sending a
message to UIScrollView from HomePageViewController's viewWillAppear
e.g.
[self.navigationController.parentViewController performSelector:#selector(enableScrollAgain)];
2 designated the RootViewController as a UINavigationController delegate to handle its
events
None seems to work so far. All advice appreciated!
Have you tried using Notifications ? You could add the RootView to observe a notification form the navigation controller, when you get that notification you can disable scrolling. Look into NotificationCenter.
Hope this helps