2010-04-29 67 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