我讀過,UITabBarController的子類化是一個不推薦的做法。但是,如何才能實現延遲加載標籤欄項目的視圖?我正在玩一個標準的應用程序視圖層次結構:在我的主應用程序委託文件(應用程序:didFinishLaunchingWithOptions :)中,我實例化一個具有4個選項卡欄的項目/圖標的UITabBarController的自定義子類。我只需要加載第一個標籤欄項目的第一個視圖 - 其他視圖應該根據請求延遲加載。所以,在應用程序中:didFinishLaunchingWithOptions:,我加載歡迎視圖並將其推入第一個UINavigationController(1)。其他標籤欄項目是空的UINavigationControllers - (2,3,4)。這裏是我的UITabBarController的自定義子類,這也是刪除自己:iOS:UITabBarController - 延遲加載項目視圖
@interface MainUITabBarController : UITabBarController <UITabBarControllerDelegate> {
}
@end
@implementation MainUITabBarController
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
UIImageView *image = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TableViewBG.jpg"]] autorelease];
UIViewController *vc = [self.viewControllers objectAtIndex:item.tag];
vc.view = image;
}
@end
目前,第二個標籤欄項目的視圖僅僅是一個UIViewController,但我會很快成爲一個UINavigationController :)
所以,回到這個問題,還有哪些(更多的蘋果投訴)選項可以實現延遲加載的標籤欄項目操作處理?
謝謝。有時候一個問題根本不是問題:) – Centurion 2011-08-07 21:12:37
我知道對:D但是我們從中學到了東西,這一切都很好! – REALFREE 2011-08-07 23:12:25