App Opening to Blank Black Screen - objective-c

I am making an app that embeds a navigationcontroller into a tabbarcontroller. Now when I open the app I am getting just a blank black screen.
Here is my code
PDCFirstViewController *viewController1 = [[PDCFirstViewController alloc]
initWithNibName:#"PDCFirstViewController" bundle:nil];
PDCSecondViewController *viewController2 = [[PDCSecondViewController alloc]
initWithNibName:#"PDCSecondViewController" bundle:nil];
ViewController *viewController3 = [[ViewController alloc]
initWithNibName:#"ViewController" bundle:nil];
UINavigationController *navigationcontroller = [[UINavigationController alloc]
initWithRootViewController:viewController3];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray
arrayWithObjects:viewController1,viewController2,navigationcontroller, nil];
[self.window makeKeyAndVisible];
Do I need to add something or do something different to make the app display? Any assistance would be great! Thank you!

You are missing rootviewcontroller
Add this
self.window.rootViewController = self.tabBarController;
Hope it helps you..

self.window.rootViewController = self.tabBarController;

self.window.rootViewController = self.tabBarController;
That should do it

Related

Set view controller as the first controller in UITabBarController

I have this code in my appDelegate.m that implements a UINavigationController with a UITabBarController:
FristViewController *primeiro = [[FristViewController alloc] init];
UINavigationController *nav1 = [[UINavigationController alloc] init];
[nav1 pushViewController:primeiro animated:YES];
FilesViewController *segundo = [[FilesViewController alloc] init];
UINavigationController *nav2 = [[UINavigationController alloc] init];
[nav2 pushViewController:segundo animated:YES];
InfoViewController *terceiro = [[InfoViewController alloc] init];
UINavigationController *nav3 = [[UINavigationController alloc] init];
[nav3 pushViewController:terceiro animated:YES];
UITabBarController *tabbar = [[UITabBarController alloc] init];
tabbar.viewControllers = [NSArray arrayWithObjects:nav2, nav1, nav3, nil];
nav1.tabBarItem.image = [UIImage imageNamed:#"tab1.png"];
nav2.tabBarItem.image = [UIImage imageNamed:#"tab2.png"];
nav3.tabBarItem.image = [UIImage imageNamed:#"tab3.png"];
self.window.rootViewController = tab bar;
It's all right with this code, in my case when I beginning my app appearing on the first controller is FilesViewController because it is the first in the order of Tab Bar, but in my case I would like the first controller was the FristViewController without changing the order of items in the tab bar, how can I do this?
Go to your storyboard or xib where you created your TabBar. Drag the First controller to 1st position. Or programmatically you could set tabBar.selectedIndex = 0;

ios7 Tabbar covers tableview

I have a new ios7 tabbar app. the app delegate looks something like this.
SomeViewController *someView = [[SomeViewController alloc] initWithNibName:#"SomeViewController" bundle:nil];
UINavigationController *someNav = [[UINavigationController alloc] initWithRootViewController:someView];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:someNav, nil];
self.tabBarController.delegate = self;
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
SomeViewController is a simple view with a full size UITableView embedded. Now when the application runs the tableview will not scroll above the tab bar.
I have tried many many suggestions, such as
self.edgesForExtendedLayout = UIRectEdgeNone;
self.tabBarController.tabBar.translucent = NO;
but nothing seems to work. In IB I turn on the guides and set the height of the table view to be above the tab bar but that doesnt work either.
Rather stuck on something I am sure is very simple.
TIA
Does:
self.tabBarController.edgesForExtendedLayout = UIRectEdgeNone
help?

UINavigationBar is under StatusBar

I'm developing a tiny app. And I'm having a problem I can't solve. I'm pushing a viewController to a navigationController and this screenshot is showing what's happening.
This is the code I'm using:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.navController = [[UINavigationController alloc] init] ;
[self.window setRootViewController:navController];
[self.window makeKeyAndVisible];
TestViewController *testViewController =[[TestViewController alloc] init];
[navController pushViewController:testViewController animated:YES];
It's driving me crazy, I been gogling for an hour without success, any idea how to fix this?
Update
Is something related with the statusbar. If I change in the info.plist file the "Status Bar is initially hidden" to "NO", then the app works fine but the status bar is shown in the launch screen. Any Idea?
Try initializing your nav controller differently
TestViewController *testViewController =[[TestViewController alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController:testViewController];
[self.window setRootViewController:self.navController];
[self.window makeKeyAndVisible];
And for sake of all saints use capital letters for class names.
What I finally did is positioning the UINavigationBar manually. I hope it helps someone else!

UITabBarController Cropped

I have a button in a viewcontroller that loads a motherViewController. This seems to be working correctly but for some reason the newly introduced view is so tall that the content at the bottom of are cropped.
- (IBAction)LoginButton:(UIButton *)sender
{
FirstViewController *FirstView = [self.storyboard instantiateViewControllerWithIdentifier:#"First"];
SecondViewController *SecondView = [self.storyboard instantiateViewControllerWithIdentifier:#"Second"];
ThirdViewController *ThirdView = [self.storyboard instantiateViewControllerWithIdentifier:#"Third"];
FourthViewController *FourthView = [self.storyboard instantiateViewControllerWithIdentifier:#"Fourth"];
FifthViewController *FifthView = [self.storyboard instantiateViewControllerWithIdentifier:#"Fifth"];
FirstView.Username = self.UsernameBox.text;
UINavigationController *FirstNavController = [[UINavigationController alloc]init];
[FirstNavController pushViewController:FirstView animated:NO];
UINavigationController *SecondNavController = [[UINavigationController alloc]init];
[SecondNavController pushViewController:SecondView animated:NO];
UINavigationController *ThirdNavController = [[UINavigationController alloc]init];
[ThirdNavController pushViewController:ThirdView animated:NO];
UINavigationController *FourthNavController = [[UINavigationController alloc]init];
[FourthNavController pushViewController:FourthView animated:NO];
UINavigationController *FifthNavController = [[UINavigationController alloc]init];
[FifthNavController pushViewController:FifthView animated:NO];
tabBar = [[UITabBarController alloc]init];
tabBar.viewControllers = [NSArray arrayWithObjects:FirstView, SecondView, ThirdView, FourthView, FifthView, nil];
[self.view addSubview:tabBar.view];
}
I don't whether i'm right or not. But here's the answer, you are trying to add UIViewController (UITabbarController) to your ViewController. So you need to position it in your view, for example
tabbar.view.frame = CGRectMake(0, 0, 320, 460);
But only thing i don't know its how it's perfectly positioned, when we are adding to window. Try your code by setting frame for your tabbarcontroller.
try this -
tabBar.tabBar.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;

adding a uinavbaritem across all views

I have a uitabbarcontroller with uinavigation controller for 2 view controllers. i am trying to have a uinavigationitem (something like "settings" that exist in most of the apps). I am wondering if I need to define this item in every view (tabOneViewController, tabTwoViewController, etc.), or is there a global way to define this buttons so it will stay when I move between different tabs?
here is how I create my tab/nav controllers in my AppDelegate:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *viewController1 = [[FirstTab alloc] initWithNibName:#"FirstTab" bundle:NSBundle.mainBundle];
UINavigationController *firstNavController = [[UINavigationController alloc]initWithRootViewController:viewController1];
UIViewController *viewController2 = [[SecondTab alloc] initWithNibName:#"SecondTab" bundle:NSBundle.mainBundle];
UINavigationController *secondNavController = [[UINavigationController alloc]initWithRootViewController:viewController2];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:firstNavController, secondNavController, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];