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是一个小的工作示例。
你的帮助是高度赞赏。