I started my project back in xcode 3 as "tabbed Application" in order to have a tab bar setup in Interface Builder.
Now I have good reasons to create my tab bar window programatically.
I have read lots of stuff and managed to create a new project with coded tab bar and all of that works fine. Therefore I believe that I understood how to create a tab bar project from scratch based on a new "Empty Application" (I think that was called "Window based application" in xcode 3).
However, when I try to adopt that code to my ongoing project that was started as "tabbed application" then I always get: "Applications are expected to have a root view controller at the end of application launch" on the debug console.
What do I have to do to change my project type from "tabbed application" to "empty application" retrospectively? Or is the only way to start a new project from scratch and copy all source files over from the old one?
BTW: googling the error message lead me to this excellent Thread: Applications are expected to have a root view controller at the end of application launch
Unfortunately none of the suggested solutions works for me. That is why I assume that my problem is related to the different types of projects from start.
Edit: I was asked to provide the didFinshWithLaunching code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent];
#ifdef FREE
window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.tabBarController = [[[FcTabBarController alloc] init] autorelease];
VotingMenuTVC *vc0 =[[[VotingMenuTVC alloc] initWithNibName:@"VotingMenuTVC" bundle:nil] autorelease];
ChannelsTVC *vc1 =[[[ChannelsTVC alloc] initWithNibName:@"ChannelsTVC" bundle:nil] autorelease];
NSArray* controllers = [NSArray arrayWithObjects:vc0, vc1, nil];
tabBarController.viewControllers = controllers;
// Add the tab bar controller's current view as a subview of the window
float ver = [[[UIDevice currentDevice] systemVersion] floatValue];
if (ver >= 4.0) {
self.window.rootViewController = self.tabBarController;
} else {
[window addSubview:[tabBarController view]];
}
[window addSubview:[tabBarController view]];
NSLog(@"RootViewController: %@",self.window.rootViewController);
NSLog(@"TabBarController: %@",self.tabBarController);
#else
float ver = [[[UIDevice currentDevice] systemVersion] floatValue];
if (ver >= 4.0) {
self.window.rootViewController = self.tabBarController;
} else {
[window addSubview:[tabBarController view]];
}
#endif
[self.window makeKeyAndVisible];
return YES;
}
For the current Target the compiler macro "FREE" was set. Otherwise it will compile for another targent for which the MainWindow.xib is still there (and works fine). Currently MainWindow.xib is still part of the Boundle, even the one for which FREE is set. But it is not set as main interface in the plist file for the target. The main interface is blank.
According to the NSLog statements (and debugging analyses) the toolBarController property is fine but the window's rootViewController is nil, which I don't understand.
As there has been a question from Firoze Lafeer asking wether MainWindow.xib still exists, that is the nex thing that I will change. I will update this post later depeding on the outcome.