This code was working well until iOS 7 release. I'm assigning a UIViewController, with hidesBottomBarWhenPushed as YES, as the rootViewController of an UINavigationController. But the TabBar is being shown anyway. Here's the relevant code:
Login *lv = [[Login alloc] init];
lv.HowToUseShows = showHowToUse;
lv.hidesBottomBarWhenPushed = YES;
UINavigationController *BokShelfNav = [[UINavigationController alloc] initWithRootViewController:lv];
//...
UITabBarController *tbController = [[UITabBarController alloc] init];
tbController.viewControllers = #[BokShelfNav,...];
Anyone with a similar problem?
I found that the order in which methods are called and properties are set has an impact on whether the tab bar is shown.
If I put self.hidesBottomBarWhenPushed = YES; in the viewDidLoad method of the view controller I'm pushing the tab bar still shows. If I moved it to the init method the tab bar hides as it used to on iOS 6.
The only workaround I've found is to make the tabBarController start in another tab ([tbController setSelectedIndex:1];), and then, in the viewWillAppear: method of that tab ViewController do [tbController setSelectedIndex:0];
I have set setSelectedIndex after push statement and it worked.
//created tabbar controller object
if(index==0)
[tabbarcontroller setSelectedIndex:1];
[self.navigationcontroller pushViewcontroller:tabbarcontroller anmated:YES];
[tabbarcontroller setSelectedIndex:index];
The only issue is if you are showing your controller at 0th index in that it will show. In this case I have first set mt tabbarcontroller's index as 1(different from 0). And its working.
Related
I have an apps with UISplitViewController as Root View, but for children of this view I use UINavigationController.
Although Master and Detail View is UIViewController, but I added this to UINavigationController before I set as Child of UISplitViewController, I did this because I need Title and UIBarButton, and also because I share this view for iPad and iPhone.
So this the snippet of my code:
MasterView _masterView = new MasterView;
UINavigationController _masterViewNavigation = new UINavigationController(_masterView);
DetailView _detailView = new DetailView;
UINavigationController _detailView Navigation = new UINavigationController(_detailView);
_splitView.ViewController = new UIViewController[]{_masterView, _detailView};
Everything was working before iOS 13. But when I run on iOS 13, ViewDidLoad of _masterView wasn’t called. While I need this to change image view on _masterView when the user makes changes on _detailView, although _masterView not shown.
Also WillHideViewController is not called, while I need this to add UIBarButtonItem on _detailView to show and hide _masterView.
Can you help me to find the solution?
Issue with iOS 13 Split view controller using IB. If you have navigation controller embedded to Master/Detail view controller it just loads the navigation controller.
To fix that issue create a custom class from UISplitViewController and assign that to your splitviewcontroller in storyboard and programatically add Navigation controller and masterViewcontroller to that UISplitViewController. That should load your view properly. This code goes in the viewdidload or willappear of the UISplitviewcontroller class.
Sample code. in Obj c
MasterViewController *master = [[MasterViewController alloc] init];
UINavigationController *tableViewNavigationController = [[UINavigationController alloc] initWithRootViewController:master];
UINavigationController *navC = [[UINavigationController alloc] init];
self.viewControllers = [NSArray arrayWithObjects:tableViewNavigationController,navC, nil];
This fixed my issue , Had similar issue after iOS13. Hope that help !
Im having difficulty getting the titles of the navigation bars to display along with the buttons within my tabBarController interface. Im creating the tabBarController programmatically. Here is the screenshot for reference.
I have tried putting self.navigationController.navigationBarHidden = YES; within the alloc/init method of the tabBarController which is allocated in the appDelegate and set as the windows rootViewController. I've also tried to set its title with this code self.navigationController.title = [[self.viewControllers objectAtIndex:self.selectedIndex]title ];. I have also tried using the same code within the viewDidLoad method of my tabBarController class. Within the UITabBarController's alloc/init method I do have this code to set the nav controllers that I have added to the viewControllers array.
UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:contactsTblView];
nav2.title = #"Contacts";
nav2.navigationItem.title = #"Contacts";
nav2.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemContacts tag:2];
nav2.delegate = self ;
The title that appears in the navigation bar is the title of the currently showing view controller (the top of the navigation controller's stack). You should set the title of the individual view controllers embedded in the navigation controller, not the navigation controller itself.
Additional info >>
Just noticed that in my application didFinishLaunchingWithOptions: i've got this
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIViewController *viewController = [[UIViewController alloc] init];
viewController = [storyboard instantiateViewControllerWithIdentifier:#"frontScreen"];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
Is this part of the problem?
R
=================
Hi I'm developing an app in storyboard.
I'm using the publicly available SWRevealViewController to manage some navigation bar reveal menus.
I've set up a simple UIViewController, lets call it WelcomeViewController. I've dragged a segue from the RevealViewController to my new WelcomeViewController and then I've embed in a Navigation Controller. To the navigation bar I've added a menu reveal button.
All looks good in the storyboard, however when I run in the simulator the navigation bar isn't there.
I've added
self.navigationController.navigationBarHidden = NO;
in the viewWillAppear method - to no avail.
I should mention that I've got an entire branch of viewcontrollers and functionality already coming off the revealviewcontroller with no problems.
Any help. I've search stack overflow but found nothing that matches my specific problems. All advice gratefully received.
R
The storyboard entry point needs to be from the navigation controller and not the main view controller. That should make the navigation toolbar show up in the simulator.
Try adding
[[UIApplication sharedApplication] setStatusBarHidden:NO];
in the view controller's viewDidLoad method
Because the default navigation bar property translucent is set to YES
you can set it to NO on your second view page on viewDidLoad.
navi.translucent = NO;
I am using a uipopover controller with navigation bar.Actually i want to have navigation bar inside the popover controller. i tried changing the background color of the navigation controller but it didnt look as i expected.The navigation bar buttons seems to be attached with the popover corners.Please find the screenshot attached.Below is my code which i used to create the popover.
WLViewBookmarkViewController * viewBookmarkViewController = [[WLViewBookmarkViewController alloc] initWithStyle:UITableViewStyleGrouped];
viewBookmarkViewController.delegate = self;
UINavigationController *viewBookmarkNavController = [[UINavigationController alloc] initWithRootViewController:viewBookmarkViewController];
viewBookmarkNavController.navigationBar.backgroundColor = [UIColor colorWithRed:9/255.0 green:135/255.0 blue:46/255.0 alpha:1.0];
self.bookmarkPopoverController = [[UIPopoverController alloc] initWithContentViewController:viewBookmarkNavController];
[self.bookmarkPopoverController presentPopoverFromBarButtonItem:bookmarkButtonItem permittedArrowDirections:UIPopoverArrowDirectionDown|UIPopoverArrowDirectionUp
animated:YES];
Please suggest if there are any other way to achieve this.
I would init the UIPopover controller with the UINavigationController directly
self.bookmarkPopoverController = [[UIPopoverController alloc] initWithContentViewController: viewBookmarkNavController];
Also try settings the content size of the popover by overriding -contentSizeForViewInPopover in the viewBookmarkViewController class to return a CGSize, you should get neater results this way.
I created a Xib in where i had a view for the controller which i had to add inside the popover.i added a table view and a navigation bar into the view.
I have an application that has a UITabBarController created in IB. That tbc loads 3 views which work fine up to now.
I decided to INSERT a UINavController as the starting VC and have a UITableViewController display 4 menu items in cells. Each of the 4 items will in essence load the UITabBarController put pass in a different xml file to process in order to display data in those 3 tabs.
I essentially did this at the end of the applicationDidFinishLoading:
MainMenu *rootViewController = [[MainMenu alloc] init];
navController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.window.rootViewController = navController;
[window makeKeyAndVisible];
return YES;
I then created the MainMenu as the rootViewController subclassing UITableViewController and added a hardcoded array for now which displays the 4 items I want. I had the didSelectRowAtIndexPath run this code:
tabBarController = [[UITabBarController alloc] init];
[self.navigationController pushViewController:tabBarController animated:YES];
[tabBarController release];
It turns out that when I run it, the navcontroller pushes the tab controller but only the first tab shows up. Here is a pic.
You should never push a UITabBarController from a UINavigationController. Apple clearly says this:
An app that uses a tab bar controller can also use navigation controllers in one or more tabs. When combining these two types of view controller in the same user interface, the tab bar controller always acts as the wrapper for the navigation controllers.`
That essentially means tab bar should be the parent of all other view controllers that get called. Not the other way round. You should probably change the way you present your app.
More information here.