0
我有這種情況下,我在我的應用程序中使用自定義UITabBar
。
它在設備和模擬器上的ios4上都很棒。
自定義UITabBarController SIGABRT崩潰在ios5 sdk
但使用的Xcode 4.2和iOS5的SDK不會工作運行相同的代碼,當我在這一行設置我的自定義tabBarController
的視圖控制器應用程序崩潰:
tabBarController.viewControllers = [NSArray arrayWithObjects:nc1, nc2, nc3, nil];
下面是我正在創建使用TabBar:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
tabBarController = [[MBCustomTabBarController alloc] init];
home=[[Home alloc] initWithNibName:@"Home" bundle:nil];
UINavigationController *nc1=[[UINavigationController alloc] initWithRootViewController:home];
live=[[Live alloc] initWithNibName:@"Live" bundle:nil];
UINavigationController *nc2=[[UINavigationController alloc] initWithRootViewController:live];
report=[[Report alloc] initWithNibName:@"Report" bundle:nil];
UINavigationController *nc3=[[UINavigationController alloc] initWithRootViewController:report];
//custom tabbar items
MBCustomTabBarItem *firstItem = [[MBCustomTabBarItem alloc] initWithTitle:@"headlines" image:[UIImage imageNamed:@"HOME-.png"] tag:0];
MBCustomTabBarItem *secondItem = [[MBCustomTabBarItem alloc] initWithTitle:@"live" image:[UIImage imageNamed:@"NEWS-.png"] tag:1];
MBCustomTabBarItem *thirdItem = [[MBCustomTabBarItem alloc] initWithTitle:@"report" image:[UIImage imageNamed:@"REPORT-.png"] tag:2];
[firstItem setImage:[UIImage imageNamed:@"HOME.png"] forState:UIControlStateSelected];
[secondItem setImage:[UIImage imageNamed:@"NEWS.png"] forState:UIControlStateSelected];
[thirdItem setImage:[UIImage imageNamed:@"REPORT.png"] forState:UIControlStateSelected];
nc1.tabBarItem=firstItem;
nc2.tabBarItem=secondItem;
nc3.tabBarItem=thirdItem;
[firstItem release];
[secondItem release];
[thirdItem release];
tabBarController.viewControllers = [NSArray arrayWithObjects:nc1, nc2, nc3, nil];
[nc1 release];
[nc2 release];
[nc3 release];
tabBarController.customTabBar.frame = CGRectMake(0, 480 - 49, 320, 49);
tabBarController.customTabBar.backgroundColor = [UIColor clearColor];
tabBarController.customTabBar.itemWidth = 320/[self.tabBarController.viewControllers count];
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
return YES;
}
而且here是一個小的工作示例。
你的幫助是高度讚賞。