开发者

tab bar presenting performance issue

开发者 https://www.devze.com 2023-04-12 11:10 出处:网络
i have a view controller with some custom buttons in it, AND A开发者_如何学PythonFTER CLICKING a button i am presentingdifferent view .and to one of the button click i am presenting a tab bar controll

i have a view controller with some custom buttons in it, AND A开发者_如何学PythonFTER CLICKING a button i am presenting different view .and to one of the button click i am presenting a tab bar controller with navigation controller .

and the code is as follows

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

and in tab bar the code is as follows

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];

the main problem is while clicking the button to present the tab bar view it takes time to load ie for a moment it appears as if the view is hanged and i am presenting a navigation view in another button and it is working fine with out any delay . please tell me whats wrong with my code and how to rectify the delay to present a tab bar while clicking a uibutton in iphone.

thanks in advance


Below code is written into the Appdelegate file and then this method is call on the button when tap on the button this method is call.

-(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];

 }

Following code for the Animation for navigate the view controller.

-(void)animationTabBarCode{

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


 tr.delegate=self;    

[self.window.layer addAnimation:tr forKey:nil]; }

following code is implanted into the button which located view controller method file.

-(IBAction)btnTapped:(id)sender{

[appDelegate ShowTabAbout];

 [appDelegate animationTabBarCode];  

}

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号