Navigation Bar not visible in simulator but visible in storyboard - ios

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;

Related

ios: TableViewControl in TabViewControl the navigation bar overlaps table view

The root View View controller is Navigation controller and its first level is a TabViewController.One of the tab item is a TableViewController.
Here is the relationship:
However the navigation bar overlap the table view:
I have also set simulated metrics,So what can be the problem??
Thanks for any help.
Simulated metrics are just that, simulated. They do not actually apply to the compiled product.
To fix this, I find it easiest to set the edgesforextendedlayout with the various values of edge values. Usually all but the top.
The rootViewController should be the UITabBarController. Follow this code:
1.Make the UITabBarController the rootViewController in the application delegate or in your main.storyboard set it as the initial View Controller.
2.In the UITabBarController.m place this code there to create the UINavigationController with a UIViewController embeded inside of it.
//Inside UITabBarController.m
- (void)viewDidLoad {
[super viewDidLoad];
UIViewController *vc = [[UIViewController alloc]init];
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:vc];
self.viewControllers = #[navCon];
}
Get rid of the navigation controller in the beginning and, instead, embed the tableviewcontroller inside a navigation controller.
(Select the view controller -- Click "editor" > "embed in" > "navigation controller").
Make sure the tab bar controller is the root view controller as well
This will also fix the overlapping issue

iphone application contains both Navigation Bar and Tab bar. With what i start creating my Project, SingleView app OR Tab bar based App?

I am creating an application that contains the Use of both Navigation Bar along with Tab bar. For Some screens in the App we are not showing the tab bar.
But most of the screens of the Applications are showing the Tab bar.
So my question is with which option i should start to create my Project?
i.e With the single view Application OR with Tab-based Application. Also out of 30 pages of the application only 5-6 pages are there that are not showing the Tab bar.
Apart from these all the screens are showing Tab bar.
So please suggest me an efficient and most useful way to start my project with. Also if i am creating my project with single view Application then how can i create an Tab bar with Navigation Bar with xib only. I don't want to use storyboard.
Also what if i start my application with Tab based and hide the tab bar for the pages that don't need to show.
Please someone suggest me.
If you need a Tab Bar Controller to be present then It should be added as your root view, I suggest start with your Tab Bar Controller and embed that in a Navigation controller
EDit---
If you want to load the viewCOntroller first then You may have to add that to your window in your appdelegate
ViewController *vc=[[ViewController alloc]initWithNibName:#"ViewController" bundle:nil];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
now when you want to show your tabBarCOntroller through button then in the buttons IBAction just do this…
-(IBAction)button:(id)sender{
UIApplication *appdelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
ViewController *vc=[[ViewController alloc]initWithNibName:#"ViewController" bundle:nil];
tabBarController= [[tabBarController alloc]init];
[tabBarController setViewControllers:#["your viewControllers"]];
UINavigationController * navigationController = [[UINavigationController alloc] initWithRootViewController:tabBarController];
appdelegate.window.rootViewController = navigationController;
[appdelegate.window makeKeyAndVisible];
}

Making your custom view controller to be the root IOS

I have a main view controller using a navigation controller and i was making my application over that. Now i want to add a welcome view controller for my app and make it show first instead of my main view controller. Is there any way to do it.
What I did was adding a view controller to my storyboard and added two classes of the same name then i made it my root view controller and unchecked the root view controller from the main view but it is not showing on the window. Please help me, that how can i make my welcome view to appear before the main view controller. Thanks
Inside Interface Builder, under the attributes section (looks like a small slider) about a quarter of the way down the list of settings, there is a section labeled "View Controller." The second item in that section is a checkbox "Is Initial View Controller," check that box and you should see the starting arrow of the story board move to the specified view controller and the app should launch to that page.
Hope this Helps.
You could do this programmatically by setting the app window's rootViewController. From the app delegate's application:didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIScreen *mainScreen = [UIScreen mainScreen];
self.window = [[KTAppWindow alloc] initWithFrame:mainScreen.bounds];
[window makeKeyAndVisible];
window.rootViewController = [[WelcomeViewController alloc] init];
return YES;
}
Then you just need to set up your trigger to switch from the Welcome view to the main view. This could be scheduling an NSTimer, for example. Whatever the trigger is, once it occurs just change the window's rootViewController instance to your MainViewController.
I hope this helps.
It calls "Splash Screen" you just need to add a new ViewController in your Storyboard or if you don't have a Navigation Controller add.
In the Splash class, in the viewDidLoad method you need to put this:
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
HomeViewController *vc = [sb instantiateViewControllerWithIdentifier:#"Home"];
[[[[UIApplication sharedApplication] delegate] window] setRootViewController:vc];
[self performSegueWithIdentifier:#"Home" sender:self];
here you can add conditions if you needed

hidesBottomBarWhenPushed ignored in iOS 7

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.

iOS: Adding navigation bar from XIB

I have been seeing this issue and resolving it by manually creating UINavigationController in the code. Could someone please tell me when I add Navigation Bar from XIB's Attribute Inspector -> Set Top bar to Black Navigation bar, it gets displayed in the XIB but when I run the program, it doesn't appear! I noticed that self.NavigationController was coming nil so I added UINavigationController in my XIB and assign NIB but still it's nil! What's wrong with this? Do I need any additional settings?
[EDIT1]
I tried adding it like below and it works but I want parent class to forward rotation and appearance events to child controller automatically. If I do following it won't send them because I am adding nvc as child and not marketsListViewController. So I thought I have to subclass UINavigationController. See EDIT2.
self.marketsListViewController = [[MarketsListViewController alloc] initWithNibName:#"MarketsListViewController" bundle:nil];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:self.marketsListViewController];
nvc.navigationBar.barStyle = UIBarStyleBlack;
[self.marketsListView addSubview:nvc.view];
[self addChildViewController:nvc];
[nvc didMoveToParentViewController:self];
[EDIT2]
I have subclassed marketsListViewController to UINavigationController and thought following will work but it doesn't. It just displays navigation bar, UITableView doesn't get displayed!
self.marketsListViewController = [[MarketsListViewController alloc] initWithNibName:#"MarketsListViewController" bundle:nil];
self.marketsListViewController.navigationBar.barStyle = UIBarStyleBlack;
[self.marketsListView addSubview:self.marketsListViewController.view];
[self addChildViewController:self.marketsListViewController];
[self.marketsListViewController didMoveToParentViewController:self];
[EDIT3]
I was wrong in Edit1 that children controller won't get rotation events when I add child as navigation controller's root controller. Parent still sends all the events automatically and that's what I want! :)
Could someone please tell me when I add Navigation Bar from XIB's
Attribute Inspector -> Set Top bar to Black Navigation bar, it gets
displayed in the XIB but when I run the program, it doesn't appear!
What you see in you .xib file is just there to help you get your layout right and get a good idea of what it'll look like. When you have an app that uses a navigation bar, the bar is almost always managed by a navigation view controller (UINavigationController). The view controllers that the navigation controller hosts don't worry about the nav bar -- their view hierarchies go in the space beneath the bar.
So, the right way to get a navigation bar in your app is almost certainly to use a navigation controller. If you only have one view controller, make that that the navigation controller's root view controller (note: the root view controller of the window will be the navigation view controller). You can change the appearance of the bar from your view controller by setting the navigation bar's style:
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
Update: In the code you posted, you're just creating a new navigation controller, but not doing anything with it. I alluded above the the fact that (in most cases) the navigation controller should be the window's root view controller. It's fine to create your navigation controller in code, but you'll usually do it in the app delegate, and once you create it you'll set it as the window's root view controller. Here's an example borrowed from a project made fresh from Xcode's master/detail template (sans storyboards):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:#"MMMasterViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
Note that after creating the window and the navigation controller, the code sets the nav controller as the window's root view controller.

Resources