我正在创建一个应用程序,它使用tabbar.i创建了一个名为setuptabbar的函数,该函数调用所有使用tabbar的类。这是我的代码。
-(void)setupTabbar{
//this is used to allocate space for tab bar item.
TJourneylistController *journeylist =[[TJourneylistController alloc]initWithNibName:nil bundle:nil];
UINavigationController *journeylistnavigation =[[UINavigationController alloc]initWithRootViewController:journeylist];
[journeylist.tabBarItem initWithTitle:@"Journey List" image:[UIImage imageNamed:@""] tag:2];
[journeylist release];
TAppStoreController *appstore =[[TAppStoreController alloc]initWithNibName:nil bundle:nil];
UINavigationController *appstorenavigation =[[UINavigationController alloc]initWithRootViewController:appstore];
[appstore.tabBarItem initWithTitle:@"App Stroe" image:[UIImage imageNamed:@""] tag:1];
[appstore release];
TSettingsController *settings =[[TSettingsController alloc]initWithNibName:nil bundle:nil];
UINavigationController *settingsnavigation =[[UINavigationController alloc]initWithRootViewController:settings];
[settings.tabBarItem initWithTitle:@"Journey List" image:[UIImage imageNamed:@""] tag:3];
[settings release];
TAboutController *about =[[TAboutController alloc]initWithNibName:nil bundle:nil];
UINavigationController *aboutnavigation =[[UINavigationController alloc]initWithRootViewController:about];
[about.tabBarItem initWithTitle:@"Journey List" image:[UIImage imageNamed:@""] tag:4];
[about release];
mTabController.viewControllers = [[NSArray alloc] initWithObjects:appstorenavigation,journeylistnavigation,settingsnavigation,aboutnavigation,nil];
[appstorenavigation release];
[journeylistnavigation release];
[settingsnavigation release];
[aboutnavigation release];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
mTabController = [[UITabBarController alloc]init];
[self setupTabbar];
if([launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]!=nil)
mTabController.selectedViewController = [mTabController.viewControllers objectAtIndex:0];
[mTabController presentModalViewController:mViewController animated:YES];
//Screen *screen =[[Screen alloc]initWithNibName:@"Screen" bundle:nil];
[window addSubview:mTabController.view];
[self.window makeKeyAndVisible];
//[screen release];
return YES;
}
但是当我运行项目时,它给了我一个错误,'应用程序试图呈现一个零模态视图控制器。问题是什么。
答案 0 :(得分:0)
在你的行中:
[mTabController presentModalViewController:mViewController animated:YES];
您正在从mTabController呈现mViewController。什么是mViewController?这可能是因为从未分配过mViewController。如果删除此行,我认为您的代码正在运行。