2010-04-29 26 views
0

我得到一个内存泄漏警告与UITabbarcontroller。解决内存泄漏会阻止我的UI显示iphone

如果我释放tabbarcontroller警告消失,但使用TabBar将不会显示任何内容。如果我调试应用程序与警告仍然处于它的应用程序运行,但一两分钟

UITabBarController *tabBarController = [[UITabBarController alloc] init]; 
    tabBarController.view.frame = CGRectMake(0, 0, 320, 460); 
    tabBarController.viewControllers=localControllersArray; 
    // Clean up objects we don't need anymore 
    [promoTabOptionHome release]; 
    [promoTabOptionInfo release]; 
    [promoTabOptionEvents release]; 
    [promoTabOptionBuy release]; 
    [localControllersArray release]; 

    // Finally, add the tab controller view to the parent view 
    [self.view addSubview:tabBarController.view]; 
    //[tabBarController release]; commenting out this line removes the warning but results in no content being shown 

回答

1

您需要到标签栏控制器的引用存储在一个实例变量,只要保持它后会崩溃你用吧。否则,只要释放它,控制器就会被释放。

+0

我使标签栏控制器成为该类的成员,并将其设置为在dealloc函数中释放。 谢谢 – dubbeat 2010-04-29 11:06:55