我有一个带有一些自定义按钮的视图控制器,并且在点击一个按钮后我会呈现不同的视图。然后按下一个按钮点击我正在呈现带有导航控制器的标签栏控制器。
,代码如下
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 :(得分: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; // [自我 animationTabCode]; [window addSubview:tabctr.view];
}
使用动画代码导航视图控制器。
- (void)animationTabBarCode {
tr.type=kCATransitionPush; tr.subtype=kCATransitionFromRight; tr.delegate=self;
[self.window.layer addAnimation:tr forKey:nil]; }
将以下代码植入到位于视图控制器方法文件的按钮中。
- (IBAction)btnTapped:(id)sender {
[appDelegate ShowTabAbout];
[appDelegate animationTabBarCode];
}