UITabBarController setViewControllers results in empty array of view controllers?
UITabBarController setViewControllers results in empty array of view controllers?
- Subject: UITabBarController setViewControllers results in empty array of view controllers?
- From: "Liza Witz" <email@hidden>
- Date: Fri, 3 Oct 2008 14:35:28 -0600
Greetings-
I've recently refactored my iPhone app to stop using an XIB to load my
view controllers. So, rather than specifying a TabBarController in
IB I'm doing so in code. The view controllers I'm adding to it were
mostly specified in code previously. What happens is, I create the
TabBarController, add the views, then query the TabBarController for
its array of views and get null. When running, the TabBar does show
up, but it shows up without any views . Somewhow the views are being
lost.
If you'll notice from the logged output, the array of view controllers
are valid, but after adding them, the tab bar says its array of view
controllers is null. This all happens within the same event loop, so
it can't be a memory issue...
Code:
tabBar = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
tabBar.delegate = self;
// hook navigation controller to one of the tabs
// hook the inner views up to the tab bar
NSArray * tabControllers = [NSArray
arrayWithObjects:dataNavigationController, searchController,
settingsController, lockController, nil];
Log(@"Controllers array: %@", tabControllers);
[tabBar setViewControllers:tabControllers animated:NO];
Log(@"tabBar is: %@", [tabBar description]);
Log(@"tabBar.viewController count: %d", [tabBar.viewControllers count]);
Log(@"tabBar.viewControllers: %@", tabBar.viewControllers);
What it puts out at runtime:
2008-10-02 03:52:14.672 Vault[55179:20b] RootViewController.m:331
-[RootViewController configureForLogin] Controllers array: (
<UINavigationController: 0x474e190>,
<SearchTableViewController: 0x47215e0>,
<SettingsViewController: 0x4721eb0>,
<LockViewController: 0x47223d0>
)
2008-10-02 03:52:14.673 Vault[55179:20b] RootViewController.m:333
-[RootViewController configureForLogin] tabBar is:
<UITabBarController: 0x474e360>
2008-10-02 03:52:14.673 Vault[55179:20b] RootViewController.m:334
-[RootViewController configureForLogin] tabBar.viewController count: 0
2008-10-02 03:52:14.674 Vault[55179:20b] RootViewController.m:335
-[RootViewController configureForLogin] tabBar.viewControllers: (null)
So, how is it tabControllers has an array of valid objects, but
setViewControllers results in tabBar.viewControllers returning null?
Is there some other way to set the view controllers on a tab bar?
FWIW, previously the code set the property directly:
tabBar.viewControllers = tabControllers;
This gave the exact same results.
I'm stuck here, and unfortunately, I suspect its something obvious!
Liza
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden