使用xcode4.2的Iam我在單視圖應用程序中爲tabbar添加了3個項目。必須應用單視圖應用程序的tabbar
的問題是我不能想象的輸出,而不是一個黑色的屏幕顯示在iOS模擬器
誰能幫我請
我的代碼是
@synthesize window = _window;
@synthesize viewController = _viewController;
@synthesize appNavigation = _appNavigation;
- (void)dealloc
{
[_window release];
[_viewController release];
[_appNavigation release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
UITabBarController *tabController = [[UITabBarController alloc] init];
NSMutableArray *tabsArray = [[NSMutableArray alloc] init];
`enter code here`ViewController *homeScreen = [[ViewController alloc] init];
homeScreen.navigationItem.title = @"App Title";
_appNavigation = [[UINavigationController alloc]initWithRootViewController:homeScreen];
_appNavigation.tabBarItem.title = @"Home";
[_appNavigation.tabBarItem setImage:[UIImage imageNamed:@"Home_Button.png"]];
[tabsArray addObject:_appNavigation];
[_appNavigation release];
BookmarksViewController *bookMark = [[BookmarksViewController alloc] init];
bookMark.navigationItem.title = @"Bookmarks";
_appNavigation = [[UINavigationController alloc] initWithRootViewController:bookMark];
[_appNavigation.tabBarItem initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:2];
_appNavigation.tabBarItem.title = @"Bookmarks";
[tabsArray addObject:_appNavigation];
[_appNavigation release];
AppSettingsController *settings = [[AppSettingsController alloc] initWithStyle:UITableViewStyleGrouped];
settings.navigationItem.title = @"Settings";
_appNavigation = [[UINavigationController alloc] initWithRootViewController:settings];
_appNavigation.tabBarItem.title = @"Settings";
[_appNavigation.tabBarItem setImage:[UIImage imageNamed:@"Settings_Button.png"]];
[tabsArray addObject:_appNavigation];
[_appNavigation release];
SearchViewController *searchView = [[SearchViewController alloc] init];
searchView.navigationItem.title = @"Ranga";
_appNavigation = [[UINavigationController alloc] initWithRootViewController:searchView];
_appNavigation.tabBarItem.title = @"Search";
[_appNavigation.tabBarItem initWithTabBarSystemItem:UITabBarSystemItemSearch tag:4];
[tabsArray addObject:_appNavigation];
[_appNavigation release];
tabController.viewControllers = tabsArray;
LoginViewController *loginView = [[LoginViewController alloc] init];
[self.window addSubview:tabController.view];
[tabController presentModalViewController:loginView animated:NO];
[self.window makeKeyAndVisible];
return YES;
}
@end
請張貼您的代碼。 –
我已經採取單視圖應用程序出故事板,我有xib文件there.i分別添加3個視圖控制器我有.h .m和.xib文件。 – user1986984