Bug 7221 - Initial layout of UITabBarController is messed up
Summary: Initial layout of UITabBarController is messed up
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.99.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-09-17 09:30 UTC by Manuel Koetter
Modified: 2012-09-24 05:48 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Manuel Koetter 2012-09-17 09:30:59 UTC
Create the following hierarchy of controllers:
1. UINavigationController
2. UITabBarController
3. UIViewController
Initially there is quite a gap between the navigation bar and the subview of tabbar-controller. When tapping another tab everything is suddenly fine again. Also manually calling tabBarController.View.LayoutSubview() helps.

The example below demonstrates the issue:

[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
	private UIWindow window;

	public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		window = new UIWindow (UIScreen.MainScreen.Bounds);
		var tabViewCtrl = new ColoredViewController();
		var tabCtrl = new UITabBarController();
		tabCtrl.ViewControllers = new UIViewController[] { tabViewCtrl };
		var navCtrl = new UINavigationController(tabCtrl);

		window.RootViewController = navCtrl;
		window.MakeKeyAndVisible ();
		return true;

	public class ColoredViewController : UIViewController
		public override void ViewDidLoad ()
			base.ViewDidLoad ();
			View.BackgroundColor = UIColor.Red;

			UIButton btn = new UIButton(UIButtonType.RoundedRect);
			btn.Frame = new System.Drawing.RectangleF(10,10, 300, 60);
			btn.SetTitle("Layout Tab Subviews", UIControlState.Normal);
			btn.TouchDown += delegate {
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-09-18 07:03:44 UTC
I can reproduce this with iOS 6 (both sim and device), but not with iOS 5 (neither sim nor device).

Note that I've tested the exact same app for both iOS5 and 6.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2012-09-18 07:26:12 UTC
I can reproduce the same issue with the following ObjectiveC code, so it does not look like a bug in MonoTouch:

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    UIViewController *tabViewCtrl = [[UIViewController alloc] init];
    UITabBarController *tabCtrl = [[UITabBarController alloc] init];
    NSArray *t1 = [[NSArray alloc] initWithObjects:tabViewCtrl, nil];
    [tabCtrl setViewControllers:t1];
    UINavigationController *navCtrl = [[UINavigationController alloc] init];
    [[navCtrl view] setBackgroundColor:[UIColor blueColor]];
    [[tabCtrl view] setBackgroundColor:[UIColor greenColor]];
    [[tabViewCtrl view] setBackgroundColor:[UIColor redColor]];
    [navCtrl pushViewController:tabCtrl animated:YES];
    UIWindow *window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
    window.rootViewController = navCtrl;
    [window makeKeyAndVisible];    
    return YES;

Comment 3 Rolf Bjarne Kvinge [MSFT] 2012-09-24 05:48:21 UTC
This seems to be a platform change (or possibly a bug) in iOS6, not MonoTouch.

I believe you can call LayoutSubview yourself to work around it.