1

I have a UITabBarController that adds a viewController, but the positioning is off. There is about a 20px gap at the top of the screen and the bottom of the loaded viewController is hidden. How do I move resize the loaded viewController?

viewController = [[FlashCardViewController alloc] initWithNibName:@"FlashCardViewController" bundle:[NSBundle mainBundle]];
viewController.view.bounds = [[UIScreen mainScreen]bounds];
//viewController.view.alpha = 0.0;
//[self.view addSubview:viewController.view];

tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
tabBarController.viewControllers = [NSArray arrayWithObject:viewController];
tabBarController.view.alpha = 0.0;
[self.view addSubview:tabBarController.view];

I tried both of these but no luck.

tabBarController.view.bounds = [[UIScreen mainScreen] bounds];
tabBarController.view.frame = [[UIScreen mainScreen] bounds];

That's not really what I am trying to do anyway. I want to set them to the tabBarController viewing window size and position.

Bryan
  • 17,201
  • 24
  • 97
  • 123

3 Answers3

5

I ended up creating the frame rect manually:

tabBarController.view.frame = CGRectMake(0,0,320,460);
Bryan
  • 17,201
  • 24
  • 97
  • 123
  • Thanks for the tip. I was able to short-cut figuring out the numbers for this code by using: self.tabBarController.view.frame = [[self view] frame] inside viewWillAppear method. – pulkitsinghal Dec 29 '11 at 16:22
1

20 pixels sounds suspiciously like the height of the status bar.

I suggest you open up your FlashCardViewController.xib file and double check that for your view under "simulated interface elements" you have nothing selected in "status bar". That should then move your view up by 20 pixels.

h4xxr
  • 11,385
  • 1
  • 39
  • 36
  • I made your suggested change, great idea, but it did not have any effect on my display. I think the problem has to do with the tabBarController. Probably 75 percent of the tabbar gets cut off at the bottom. – Bryan Aug 25 '09 at 16:28
1
CGRect screenArea = [[UIScreen mainScreen] applicationFrame];

tabBarController.view.frame = CGRectMake(0,0,screenArea.size.width,screenArea.size.height);
MD SHAHIDUL ISLAM
  • 14,325
  • 6
  • 82
  • 89
nelson
  • 19
  • 1