2011-10-10 318 views
0

我有一個視圖控制器,其中有一些自定義按鈕,然後點擊一個按鈕,我呈現不同的視圖。按一下按鈕,我將呈現一個帶有導航控制器的標籤欄控制器。標籤欄呈現性能問題

和代碼如下

TabBarView *tabbar=[[TabBarView alloc]init]; 
     UINavigationController *navNextController  = [[UINavigationController alloc] initWithRootViewController:tabbar]; 
     [self presentModalViewController:navNextController animated:YES]; 

和在標籤欄的代碼如下

UINavigationController *localNavigationController; 
tabbarcontroller = [[UITabBarController alloc] init]; 

localControllersArray = [[NSMutableArray alloc] initWithCapacity:3]; 
tabbarcontroller.delegate=self; 


ShoppingListView *shop; 
shop = [[ShoppingListView alloc] init]; 
shop.parentVC=self; 
localNavigationController = [[UINavigationController alloc] initWithRootViewController:shop]; 
[localNavigationController.tabBarItem setTitle:@"Lists"]; 
[localNavigationController.tabBarItem setImage:[UIImage imageWithContentsOfFile:[IMBundle fullBundlePath:@"Images.bundle/Images/EnhancedMobileLists/list.png"]]]; 
[localNavigationController viewWillAppear:YES]; 
[localControllersArray addObject:localNavigationController]; 
[localNavigationController release]; 
[shop release]; 

FavoritesViewController *fav; 
fav = [[FavoritesViewController alloc] init]; 
fav.parentVC=self; 
localNavigationController = [[UINavigationController alloc] initWithRootViewController:fav]; 
[localNavigationController.tabBarItem setTitle:@"Favorites" ]; 
[localNavigationController.tabBarItem setImage:[UIImage imageWithContentsOfFile:[IMBundle fullBundlePath:@"Images.bundle/Images/EnhancedMobileLists/favorites.png"]]]; 
[localNavigationController viewWillAppear:YES]; 
[localNavigationController viewWillDisappear:YES]; 
[localControllersArray addObject:localNavigationController]; 
[localNavigationController release]; 
[fav release]; 

ShareListViewController *share; 
share = [[ShareListViewController alloc] init]; 
share.parentVC=self; 
localNavigationController = [[UINavigationController alloc] initWithRootViewController:share]; 
[localNavigationController.tabBarItem setTitle:@"Share" ]; 
[localNavigationController.tabBarItem setImage:[UIImage imageWithContentsOfFile:[IMBundle fullBundlePath:@"Images.bundle/Images/EnhancedMobileLists/share.png"]]]; 
[localNavigationController viewWillAppear:YES]; 

[localControllersArray addObject:localNavigationController]; 
[localNavigationController release]; 
[share release]; 

tabbarcontroller.viewControllers = localControllersArray; 
[self.view addSubview:tabbarcontroller.view]; 

的主要問題是,同時點擊該按鈕來呈現標籤欄查看它需要一定的時間加載即暫時看起來好像視圖被吊起來,我在另一個按鈕中呈現導航視圖,並且它沒有任何延遲地工作正常。請告訴我我的代碼有什麼問題,以及如何解決延遲問題,以在iphone中點擊uibutton時顯示標籤欄。

在此先感謝

回答

0

下面的代碼寫入的appdelegate文件,那麼這種方法是當輕敲按鈕這個方法是調用按鈕調用。

- (void)ShowTabAbout {[viewController.view removeFromSuperview]; self.imgV.frame = CGRectMake(0,425,320,55); self.imgV.image = [UIImage imageNamed:@「tBar5.png」]; [self.tabctr.view addSubview:self.imgV]; self.tabctr.selectedIndex = 4; // [self animationTabCode]; [window addSubview:tabctr.view];

} 

以下爲動畫用於導航視圖控制器代碼。

- (無效)animationTabBarCode {

tr.type=kCATransitionPush; 
tr.subtype=kCATransitionFromRight; 


tr.delegate=self;  

[self.window.layer addAnimation:TR forKey:無]; }

將以下代碼植入到位於視圖控制器方法文件的按鈕中。

- (IBAction爲)btnTapped:(ID)發送方{

[的appDelegate ShowTabAbout];

[appDelegate animationTabBarCode]; 

}

+0

有關自定義的TabBar以下參考鏈路指更詳細http://sugartin.info/2011/07/01/customizing-tab-bar/ –