TabBarController status bar issue in iOS7 - ios

I added the UITabBarController view on the UIWindow. TabBarController view is messing up with Status Bar. The TabBarController is in the MainWindow.xib. How can i fix this?
window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
tabController.viewControllers = [NSArray arrayWithObjects:nearbySplit, mySplit, allSplit, messageSplit, nil];
tabController.selectedIndex = 0;
window.rootViewController = tabController;
[window addSubview:tabController.view];
[window makeKeyAndVisible];

Add the this code in view controller
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone; // iOS 7 specific
in your viewDidLoad method.

Related

RKSwipeBetweenViewControllers , without declaring as a root view controllers

i want to swipe between view controllers inside a tab bar. but when i declare its a root view controller, tab bar also hide and user not able to navigate between tab bars.
how can i achieve this without declaring it as a root view controllers.
UIPageViewController *pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
RKSwipeBetweenViewControllers *navigationController = [[RKSwipeBetweenViewControllers alloc]initWithRootViewController:pageController];
//%%% DEMO CONTROLLERS
UIViewController *demo = [[UIViewController alloc]init];
UIViewController *demo2 = [[UIViewController alloc]init];
UIViewController *demo3 = [[UIViewController alloc]init];
UIViewController *demo4 = [[UIViewController alloc]init];
demo.view.backgroundColor = [UIColor redColor];
demo2.view.backgroundColor = [UIColor whiteColor];
demo3.view.backgroundColor = [UIColor grayColor];
demo4.view.backgroundColor = [UIColor orangeColor];
[navigationController.viewControllerArray addObjectsFromArray:#[demo,demo2,demo3,demo4]];
[[[UIApplication sharedApplication] delegate] window].rootViewController = navigationController;
[[[[UIApplication sharedApplication] delegate] window] makeKeyAndVisible];
Below these lines of code you can add and swipe between view controllers.
[yourView addSubview:navigationController.view];
[self addChildViewController:navigationController];
[navigationController didMoveToParentViewController:self];

Why my navbar doesn't show up?

I'm trying to set my window's root view controller to a UITabBarController with a UINavigationController but for some reason the navigation bar doesn't show up. Anybody knows why?
Thanks
Here is my method:
- (void) showUserOnlyScreen
{
UITabBarController *tabbarController = [[UITabBarController alloc]init];
SSHomeViewController *homeVC = [[SSHomeViewController alloc]init];
UINavigationController *homeNav = [[UINavigationController alloc]initWithRootViewController:homeVC];
[tabbarController setViewControllers:#[homeNav]];
self.window.rootViewController = tabbarController;
[self.window makeKeyAndVisible];
}
Your code is OK.
Check if the UINavigationBar is transparent by applying a border on it:
homeNav.navigationBar.layer.borderWidth = 2.0f;
homeNav.navigationBar.layer.borderColor = [UIColor redColor].CGColor;
Check also if you mistakenly hide the navigationbar on your SSHomeViewController controller with this:
[self.navigationController setNavigationBarHidden:YES animated:NO];

UINavigationController not displaying

I am new to IOS dev so I'm sure the answer is simple but my ignorance makes it hard to find the answers online. I'm trying to use a UINavigationController to switch between views. Thus far I have been succesfully displaying the first view with the following code.
FLInitialMapViewController *control = [[FLInitialMapViewController alloc] init];
self.window.rootViewController = control;
I then wrote the code to add the navigation controller but when I run it I see mostly a black screen with a gray bar at the top of it. Here's the code
FLInitialMapViewController *control = [[FLInitialMapViewController alloc] init];
_navController = [[UINavigationController alloc] initWithRootViewController:control];
self.window.rootViewController = _navController;
Here is the complete code for AppDelegate.m in 'didFinishLaunchingWithOptions':
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
FLInitialMapViewController *control = [[FLInitialMapViewController alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController: control];
[self.navController setNavigationBarHidden:YES];
self.window.rootViewController = self.navController;
[self.window makeKeyAndVisible];
return YES;
Interestingly, the gray bar near the top is slightly translucent and I can see some of my UI elements underneath it.
EDIT: I removed the top bar and now I see the following!
This is what should be seen.
I have added navigation bar setup for your convenience. Try this in your AppDelegate.m under didFinishLaunchingWithOptions: method -
FLInitialMapViewController * control = [FLInitialMapViewController new];
UINavigationController *myNav = [[UINavigationController alloc] initWithRootViewController: control];
self.window.rootViewController = myNav;
// Setup navigation bar programmatically
UINavigationBar *navigationBar = myNav.navigationBar;
navigationBar.barTintColor = [UIColor orangeColor];
navigationBar.barStyle = UIBarStyleBlackOpaque;
// Boiler plate code from AppDelegate
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

How to display all tabBar titles in ios7

Basically i cant get to display all tabBar Items when i run my app, just the first view controller is displayed:
I literally have to click on a tab to display its Item:
This my code in Appdelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Initialize window
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
// Set background colors for both NavBar and TabBar
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.157 green:0.718 blue:0.553 alpha:1]];
[[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:0.141 green:0.216 blue:0.263 alpha:1]];
// Initialize your five tab controllers. with each tab has its own navigation controller
HomePageView *homePageView = [[HomePageView alloc]init];
UINavigationController *nav1 = [[UINavigationController alloc]initWithRootViewController:homePageView];
ProfileViewController *profileViewController=[[ProfileViewController alloc]init];
UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:profileViewController];
FeedViewController *feedViewController=[[FeedViewController alloc]init];
UINavigationController *nav3 = [[UINavigationController alloc]initWithRootViewController:feedViewController];
ListeningSessionViewController *listeningSessionViewController= [[ListeningSessionViewController alloc]init];
UINavigationController *nav4 = [[UINavigationController alloc]initWithRootViewController:listeningSessionViewController];
RecievedViewController *recievedViewController =[[RecievedViewController alloc]init];
UINavigationController *nav5 = [[UINavigationController alloc]initWithRootViewController:recievedViewController];
// initialize tabbarcontroller,set your viewcontrollers and change its color.
self.tabC = [[UITabBarController alloc]init];
NSArray* controllers = [NSArray arrayWithObjects: nav1,nav2,nav3,nav4,nav5, nil];
[self.tabC setViewControllers: controllers animated:NO];
[_window addSubview:self.tabC.view];
// Show window
[self.window makeKeyAndVisible];
return YES;
}
I'm guessing that you're setting the titles in the viewDidLoad or viewDidAppear methods of the controllers. That won't work, because, while all the controllers are instantiated in the app delegate, only the controller at index 0 has its view loaded, and thus viewDidLoad will not be run for the other controllers. Instead, you should set the titles on the navigation controllers in the app delegate,
ProfileViewController *profileViewController=[[ProfileViewController alloc]init];
UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:profileViewController];
nav2.tabBarItem.title = #"Profile";

TabBarController and NavigationController

I am making an application but I'm still a beginner and I'm trying to get used to the RootViewController and how it should be set.
At the beginning my application launches, I want there to be a View which is not in my tabBarController (which is set to be my rootViewController).
What I am trying to ask is, Can I have another view which is outside my UITabBarController launch first without it being in the tabBarController's items list?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
FacebookFeedViewController *facebookClass = [[FacebookFeedViewController alloc] initWithNibName:#"FacebookFeedViewController" bundle:nil];
TwitterFeedViewController *twitterClass = [[TwitterFeedViewController alloc] initWithNibName:#"TwitterFeedViewController" bundle:nil];
LinkedInFeedViewController *linkClass = [[LinkedInFeedViewController alloc] initWithNibName:#"LinkedInFeedViewController" bundle:nil];
FTLFullFeedViewController *masterClass = [[FTLFullFeedViewController alloc] initWithNibName:#"FTLFullFeedViewController" bundle:nil];
/// tab button title
facebookClass.title = #"Facebook";
twitterClass.title = #"Twitter";
linkClass.title=#"LinkedIn";
masterClass.title=#"FTL";
// tab button Images
facebookClass.tabBarItem.image = [UIImage imageNamed:#"facebook_32"];
twitterClass.tabBarItem.image = [UIImage imageNamed:#"twitter_32"];
WelcomeViewController *welcomeClass= [[WelcomeViewController alloc] initWithNibName:#"WelcomeViewController" bundle:nil];
navController = [[ UINavigationController alloc] initWithRootViewController:welcomeClass];
UINavigationController *navController2 = [[UINavigationController alloc] initWithRootViewController:facebookClass];
UINavigationController *navController3 = [[UINavigationController alloc] initWithRootViewController:twitterClass];
UINavigationController *navController4 = [[UINavigationController alloc] initWithRootViewController:linkClass];
UINavigationController *navController5 = [[UINavigationController alloc] initWithRootViewController:masterClass];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navController,navController5,navController2,navController3,navController4,nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
I know you already selected an answer but all that's doing is pushing a UITabBar view on top of an existing view, not creating a new UITabBarController view. Based on our brief conversation (latest XCode, no StoryBoards, using XIBs) you're going to want to create a xib as a UITabBarController then push it into view...
View *view = [[View alloc] initWithNibName:#"myUITabBarXIB" bundle:nil];
view.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController: view animated:YES];
This will present your XIB file but not on top of the existing view controller when the desired action takes place.
yes! ofcourse you do.
[self.view addsubview:yourTabbar.view];
Hope this will help you.

Resources