iPhone - App with tab bar controller - showing gap at top - iphone

I'm having a login view that accepts username and password. Upon successful authentication, i'll present a view controller that has tab bar view (IBOutlet) with 3 tabs. Each tab bar view controller has navigation controller (but no table view in any of the view controllers). Usign xib, i added tab bar controller object, then added navigation controllers under tab bar tree and added view controllers accordingly to the 3 navigation controllers.
Upon successful authentication, i'm calling
[self presentViewController:myViewController animated:YES]
This is how its being shown.
In myViewController's viewDidLoad, I'm adding tab bar as follows:
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.tabBarController.view];
}
Why is the gap seen above nav bar and below status bar. Due to that gap, tab bar at the bottom is being cut.......

It is a common problem, the tabBarController and also other Controller have by default the statusbar in its frame cordinates to resolve this, just set the bounds of your view to the frame of the tabBarController view.
tabBarController.view.frame = self.view.bounds;

In a case self.view.bounds was not in accurate position. So following was helpful to me.
self.view.frame = [[UIScreen mainScreen] bounds];
CGRect cgp = self.view.bounds;
[self.tabBarController.view setFrame:cgp];
In another case(iOS 7) tabBar hides itself to the bottom of screen. In this case
self.view.frame = [[UIScreen mainScreen] bounds];
CGRect cgp = self.view.bounds;
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
cgp.size.height = cgp.size.height-90;
}
[self.tabBarController.view setFrame:cgp];

Related

View outside screen

I have a tab controller, which contains a navigation controller which again contains a view controller. The view controller shows a tab bar and a navigation bar.
In this view controller I want to add a full screen view (hides the tab bar and the navigation bar but leaves the status bar) which is shown during loading. I have subclassed UIView and set up a layout in a nib file which is loaded to this view:
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
{
// Load nib
self = [[[NSBundle mainBundle] loadNibNamed:#"FrontpageCountdownView" owner:self options:nil] objectAtIndex:0];
}
}
I add this view in the view controller like this:
// Hide tab bar and navigation bar
self.tabBarController.tabBar.hidden = YES;
self.navigationController.navigationBar.hidden = YES;
// Add loading (frontpage countdown) view
CGRect frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
NFFrontpageCountdownView *countdownView = [[NFFrontpageCountdownView alloc] initWithFrame:frame];
[self.view addSubview:countdownView];
The view in my nib has a size of 460 (full screen, minus the status bar). My problem is, that when I add it to the view controller it appears "bigger".
I would think that since the view has a size of 460 it should show the entire view when it is added to the view controller but it doesn't show the bottom. It seems that the view is too big even though it is 460 pixels.
Can anybody tell me why this is?
EDIT
How my view looks in Interface Builder:
How my view looks in the simulator:
This happens when hiding the tab bar using self.tabBarController.tabBar.hidden = YES.
Instead, you should hide it and then extend the view of the tabBarController.
CGRect tabBarFrame = self.tabBarController.view.frame;
tabBarFrame.size.height += self.tabBarController.tabBar.frame.size.height;
self.tabBarController.view.frame = tabBarFrame;
self.tabBarController.tabBar.hidden = YES;

UINavigationBar wrong position in Landscape start

iPad app. I have a tabbar. One tab has a view controller with a view. In that view controller I add a uinavigationcontroller. If I start the app in portrait, everything works fine. However if the app starts in landscape, my navbar y position is 20 (instead of 0 which it should be). I can see the view behind the navbar. If I manually re-position (a bandaid) the uinavigationcontroller to -20 y, I get a host of sizing problems throughout the app. How can I fix this? (by the way, if i remove the status bar it sizes just fine in landscape)
Here is the code of my view that manages the navcontroller:
- (void)viewDidLoad
{
[super viewDidLoad];
self.topicsList = [[TopicsListVC alloc]initWithStyle:UITableViewStylePlain];
self.navController = [[UINavigationController alloc]initWithRootViewController:self.topicsList];
self.navController.view.frame = self.view.frame;
[self.view addSubview:self.navController.view];

Child view offset by 20 pixels in TabBar application

I have a tab bar application and when I display a modal view controller, the content screen is offset by about 20 pixels to the top and left. It looks like this:
I'm presenting this view from the child view controller (detail view) of navigation controller (main view) of the tabview.
When I show the view, I'm hiding the tab bar and navigation bar but status bar is kept visible. Adjusting the view to be centered (through Interface Builder's Simulated Interface Elements->View Mode : Center) and changing the view's frame after a call to 'viewDidLoad' in the controller doesn't seem to shift it.
- (void)viewDidLoad {
// this still doesn't cause it to shift
self.view.frame = CGRectMake(0, 20, 320, 460);
}
What's the way to adjust this so that the content area is shown correctly?
I launch the child view like this:
[detailController presentModalViewController:tvc animated:NO];
The app's view controller hierarchy:
Tab view with two child navigation controllers are created in the app delegate and the nav controllers added to the TabBar's view controllers:
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObjects:tab1ViewController,
tab2ViewController, nil];
[window addSubview:tabBarController.view];
Each view controllers of the tab is created as a NavigationController with 1 view controller:
// MainViewController inherits from UIViewController
[MainViewController *viewController = [[MainViewController alloc] initWithNib..];
tab1ViewController.viewControllers = [NSArray arrayWithObject:viewController];
A detail view controller is launched with 'pushViewController' as a result of some action on tab1ViewController :
DetailController *detailController = [[DetailController alloc]
initWithNibName:#"DetailView"
bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:detailController animated:YES];
[detailController release];
It's from the detailController that I'm trying to launch the problem controller.
Some things to check right off: is "viewDidLoad" actually getting called?
If so, what is self.view.frame set to after the assignment?
Put an NSLog at the end that prints out the x, y, width, height, and see what's there.
Also, since the trouble vc is modal, it will occupy the entire screen.
"On iPhone and iPod touch devices, the view of modalViewController is always presented full screen."
HTH,
Mike

Keep Toolbar at top of UIView when using pushViewController and then popViewController?

Update: Another solution to this problem would be if the Navigation bar at the root level of the navigation controller could be transparent or not shown. Is there a way to make the Navigation bar at the root level of the navigation controller transparent or not shown?
I have a NIB with a toolbar at the top of my top level UIView and below the toolbar is a tableView. When I use pushViewController on a navigationController to push another UIViewController onto the navigationController, the toolbar is overwritten by the navigation bar. When I pop the current view back to the root view, the toolbar cannot be seen as there is a blank bar across the top. There is now also a gap between the toolbar and the top of the tableView about the size of the toolbar. So the view looks like from the top:
1) shaded blank bar,
2) blank space about the size of a toolbar,
3) tableview
How can I make the toolbar of the top level NIB appear at the top of the UIView after using popViewController?
In the top level view I instantiate a UINavigationController:
self.navigationController = [[UINavigationController alloc] initWithRootViewController:ListsController];
and then in didSelectRowAtIndexPath I push a view controller
ItemsController * Items = [[ItemsController alloc]
initWithNibName:#"Items" bundle:nil] ;
[self.navigationController pushViewController:Items animated:YES];
To get the initial pushed view to display I do the following:
UIView *navView = self.navigationController.view;
CGRect navFrame = navView.frame;
// navFrame.origin.y -= 20;
navView.frame = navFrame;
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
UIWindow *appWindow = appDelegate.window;
[appWindow addSubview:navView];
Any idea how I can get the top level toolbar not to be overwritten when popping back to the top level?
The solution is to make the navigation bar hidden at the root level using:
- (void)viewWillAppear:(BOOL)animated {
[[self navigationController] setNavigationBarHidden:YES animated:YES];
[super viewWillAppear:animated];
[self.table reloadData];
}
Then at the next lower level of the navigation stack, make the navigation bar unhidden:
- (void)viewWillAppear:(BOOL)animated {
[[self navigationController] setNavigationBarHidden:NO animated:YES];
[super viewWillAppear:animated];
[self.table reloadData];
}

View controller is drawing under my navigation bar after popping ttthumbsviewcontroller

I'm implementing the TTThumbsViewController from the Three20 project and things are finally starting to take shape. I push the TTThumbsViewController from the current view controller by just pushing it onto the current stack and animate the transition (common navigation controller push).
My problem is that when I pop the TThumbsViewController view controller, the navigation controller is stuck in a mode where its view controllers are drawn UNDER the navigation bar (which is now translucent).
Start
Push
Pop
You need to reconfigure the original style of the status bar, navigation bar & tool bar when your view reappears. You can do this by implementing viewWillAppear: in your view controller:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
UINavigationController* navController = self.navigationController;
navController.navigationBar.barStyle = UIBarStyleDefault;
navController.navigationBar.tintColor = [UIColor redColor];
navController.toolbar.tintColor = [UIColor redColor];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
}
It looks like the view controller you are pushing from does not inherit from TTViewController. You may also need to set the 'navigationBarTintColor' property back to your original color after the view has been popped off the stack; if you have not set a global stylesheet.