2011-10-10 78 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/ –