1

I made a sample project of my problem so that you can understand it better. You can get it here:

https://github.com/nwalter08/iOS-7-Container-View-Controller-Probs

My problem is that I have a UITabBarController that holds a Container UIViewController that holds a UINavigationController that holds a UIViewController. A lot I know :)

The problem is that when I run the app on iOS 7, the UIViewController doesn't fill the space of the whole UINavigationController. When I run in iOS 6, this is not a problem.

Some special notes are that I set the translucent property on the tabBar and navigationBar to NO. I am also not using IB or storyboards.

I have color coded the View Controllers so that you can see that the UIViewController is too short and the yellow UINavigationController background is showing.

iOS 6

https://www.dropbox.com/s/lpl6wtmoy3dsn3c/iOS%20Simulator%20Screen%20shot%20Feb%206%2C%202014%2C%202.45.56%20PM.png

iOS 7

https://www.dropbox.com/s/f5r5oltb4ookteh/iOS%20Simulator%20Screen%20shot%20Feb%206%2C%202014%2C%202.46.21%20PM.png

Update -- So rdelmar's answer worked for the UIViews that had no content inside them but I found with my code that the content was stretched and didn't fit. I am pretty sure this is an iOS bug and I submitted a Radar to Apple. To solve my issue, I used a UITabBarController replacement https://github.com/jinthagerman/JBTabBarController

ZappyCode
  • 75
  • 1
  • 8

5 Answers5

1

Your problem is in the following line in the loadView method of RedContainerViewController,

UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

It's view shouldn't be the size of the screen since it's embedded in a tab bar controller. Change that line to just [[UIView alloc] init], and it should work.

rdelmar
  • 102,832
  • 11
  • 203
  • 218
0

Detail view controller is not smaller. It goes under navigationBar in iOS 7. You can set navigationBar.translucent =NO or you can set delta in your xib/storyboard ( if you have one )

Gago
  • 297
  • 1
  • 9
0

Setting the navigation bar to not be translucent doesn't mean that that view does not sit underneath it anymore. It just means that it's not visible underneath it anymore.

Set edgesForExtendLayout to UIRectEdgeNone on your view controller, and your view will actually move from underneath the navigation bar to the visible area of the view controller.

Scott Berrevoets
  • 16,581
  • 6
  • 56
  • 79
  • I have tried this and it doesn't change anything. If it works for you, please do a pull request on my github project so that I can see your code. – ZappyCode Feb 06 '14 at 22:32
0

This fixes it, but may have other side effects you don't want.

--- a/TabBarContainerNavProblem/MyTabBarViewController.m
+++ b/TabBarContainerNavProblem/MyTabBarViewController.m
@@ -31,7 +31,7 @@
         BOOL isAtLeast7 = [version floatValue] >= 7.0;

         if (isAtLeast7) {
-            self.tabBar.translucent = NO;
+            self.tabBar.translucent = YES;
         }
     }
     return self;
Bart Whiteley
  • 1,426
  • 12
  • 10
0

Please see my answer to a similar question right here.

after setting that flag, your views should position themselves as expected.

Community
  • 1
  • 1
Nick
  • 2,231
  • 13
  • 25