Convert the navbar to a tab app
I was wondering how to convert a NavigationController style app to a TabBarcontroller style app. I changed my mainwindow to no longer contain the navigation manager (but there was a tabbarcontroller instead) and my delegate, but when I start the app, it still thinks I want a navigationController:
Application terminated due to uncaught "NSUnknownKeyException", Reason: "[setValue: forUndefinedKey:]: This class is not a key value that is compatible with the encoding for the key navigation controller. '
Stack trace:
#0 0x020fa004 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___
#1 0x96fc0509 in objc_exception_throw
#2 0x020ee1c1 in -[NSException raise]
#3 0x000d8a78 in _NSSetUsingKeyValueSetter
#4 0x000d84c5 in -[NSObject(NSKeyValueCoding) setValue:forKey:]
#5 0x004fb4c8 in -[UIRuntimeOutletConnection connect]
#6 0x020af92f in -[NSArray makeObjectsPerformSelector:]
#7 0x004f9f7f in -[UINib instantiateWithOptions:owner:loadingResourcesFromBundle:]
#8 0x004fbfcb in -[NSBundle(NSBundleAdditions) loadNibNamed:owner:options:]
#9 0x0033b0a6 in -[UIApplication _loadMainNibFile]
#10 0x0034482a in -[UIApplication _runWithURL:sourceBundleID:]
#11 0x00341b88 in -[UIApplication handleEvent:withNewEvent:]
#12 0x0033d6d3 in -[UIApplication sendEvent:]
#13 0x003440b5 in _UIApplicationHandleEvent
#14 0x0265aed1 in PurpleEventCallback
#15 0x02092b80 in CFRunLoopRunSpecific
#16 0x02091c48 in CFRunLoopRunInMode
#17 0x0033be69 in -[UIApplication _run]
#18 0x00345003 in UIApplicationMain
#19 0x00002ec8 in main at main.m:14
The interface for my delegate looks like this:
@interface CPPlayerAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
}
#pragma mark -
#pragma mark Window/view
@property (retain) IBOutlet UIWindow *window;
@property (retain) IBOutlet UITabBarController *tabBarController;
My delegate implementation:
@implementation CPPlayerAppDelegate
@synthesize window;
@synthesize tabBarController;
@synthesize stateController, distribution, languageManager, updateParser, soundPlayer, ticketProcessor;
#pragma mark -
#pragma mark Application lifecycle
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview: tabBarController.view];
[window makeKeyAndVisible];
}
Where can I tell the app to be a tabbar driven app and not a navigation driven app?
Thanks in advance,
a source to share
You need to change your main XIB. Open it in the Builder interface, delete the navigation controller you have and replace it with the tab bar controller. Then bind the application delegate tabBarController
to the tab controller in the XIB. For more information on how to do this, see the Builder Interface User Guide and, more specifically, Links and Bindings .
a source to share
I found that the -Info.plist file had a link to the wrong xib file after I converted the project to an iPad app and then removed the navigation controller and replaced the new top-level view structure without it. I downloaded and edited a non-iPad xib but missed the iPad Resources folder that was created with a different xib.
Once xib took care of it, everything was fine.
a source to share