在我的功能- (void)viewDidLoad
:iphone的UITabBarController内存管理
FirstViewController *first = [[FirstViewController alloc]init];
SecondViewController *second = [[SecondViewController alloc]init];
ThirdViewController *third = [[ThirdViewController alloc]init];
ForthViewController *forth = [[ForthViewController alloc]init];
FifthViewController *fifth = [[FifthViewController alloc]init];
first.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"first" image:[UIImage imageNamed:@"FirstTab.png"] tag:0];
second.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"second" image:[UIImage imageNamed:@"SecondTab.png"] tag:1];
third.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"third" image:[UIImage imageNamed:@"ThirdTab.png"] tag:2];
forth.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"forth" image:[UIImage imageNamed:@"ForthTab.png"] tag:3];
fifth.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"fifth" image:[UIImage imageNamed:@"FifthTab.png"] tag:3];
UINavigationController *navigationFirst = [[UINavigationController alloc]initWithRootViewController:first];
UINavigationController *navigationSecond = [[UINavigationController alloc]initWithRootViewController:second];
UINavigationController *navigationThird = [[UINavigationController alloc]initWithRootViewController:third];
UINavigationController *navigationForth = [[UINavigationController alloc]initWithRootViewController:forth];
UINavigationController *navigationFifth = [[UINavigationController alloc]initWithRootViewController:fifth];
// [first release];
// [second release];
// [third release];
// [forth release];
// [first release];
NSMutableArray *array = [[NSMutableArray alloc]initWithObjects:navigationFirst,navigationSecond,navigationThird,navigationForth,navigationFifth, nil];
[navigationFirst release];
[navigationSecond release];
[navigationThird release];
[navigationForth release];
[navigationFifth release];
self.tabbarController = [[UITabBarController alloc]init];
self.tabbarController.view.frame = CGRectMake(0, 0, 320, 480);
self.tabbarController.viewControllers = array;
[array release];
我打算五个加UINavigationControllers到tabcontroller,如果我不发表意见fellowing代码,它会崩溃:
// [first release];
// [second release];
// [third release];
// [forth release];
// [first release];
但我想知道有什么问题,我认为添加thees代码是正确的。
你能给我你的代码我会尝试! – parag 2012-03-16 05:56:03