[英]UITabBarController's tabBar showed slower than controller's view
Question:I'm using UITabBarController and all is ok. 问题:我正在使用UITabBarController,一切正常。 However,When i selected a item,then present a controller in the controller of the item, after dismissing the present controller, and back to first item ,the wired thing was happened:
但是,当我选择一个项目时,然后在关闭该当前控制器后,在该项目的控制器中显示一个控制器,然后回到第一个项目,发生了有线连接:
1.pushed a controller(all is ok) 1.推一个控制器(一切正常)
2.pop the controller of top, the tabBar showed after the first controller's view having showed and with animation.it's wired. 2.弹出顶部的控制器,在显示第一个控制器的视图并显示动画后显示tabBar,并进行连线。
the normal status is tabor should show together with the first controller's view of the first barItem. 正常状态是tabor,应与第一个barItem的第一个控制器的视图一起显示。
Anyone know what should i do? 有人知道我该怎么办吗?
Thanks Advanced! 谢谢高级!
My Code is here: 我的代码在这里:
First:initial thirdNav and tabbaritem 第一:初始的第三个Nav和tabbaritem
//MainController.m(extend UITabBarController)
//....
-(YSSJNavigationController *)thirdNav{
if (!_thirdNav) {
YSSJLivingViewController *livingViewController = [[YSSJLivingViewController alloc] init];
[livingViewController setHidesBottomBarWhenPushed:YES];
_thirdNav = [[YSSJNavigationController alloc] initWithRootViewController:livingViewController];
_thirdNav.navigationBar.hidden = YES;
[_thirdNav setHidesBottomBarWhenPushed:YES];
}
return _thirdNav;
}
//....
self.thirdNav.tabBarItem = [self itemWithTitle:[arrayName objectAtIndex:4] image:[UIImage imageNamed:[arrayName objectAtIndex:5]] selectedImage:[UIImage imageNamed:[arrayName objectAtIndex:4]] ];
self.thirdNav.tabBarItem.tag = 2;
//...other navs' initial
self.viewControllers = @[firstNav,secondNav,self.thirdNav,fourthNav];
Second:present a new controller from ThirdNav's root controller //YSSJLivingViewController.m -(void)p_jumpToLivePage{ NSDictionary *options = @{ @"gid" : @(-1), @"gids" : @[], @"shortContent" : @"", @"tags" :@[], @"title" : @"", @"type" : @"live" }; 第二:从ThirdNav的根控制器//YSSJLivingViewController.m-(void)p_jumpToLivePage {NSDictionary * options = @ {@“ gid”:@(-1),@“ gids”:@ [],@“ shortContent “:@”“,@” tags“:@ [],@” title“:@”“,@” type“:@” live“}; NSMutableDictionary *liveInfo = [[NSMutableDictionary alloc]initWithDictionary:options];
NSMutableDictionary * liveInfo = [[[NSMutableDictionary alloc] initWithDictionary:options];
liveInfo = [YSSJTop setLiveInfo:liveInfo];
NSMutableDictionary *createOption = [liveInfo[@"creator"] mutableCopy];
NSArray *joinedGroups = liveInfo[@"joinedGroups"];
createOption[@"liveId"]= liveInfo[@"liveId"];
[createOption setValuesForKeysWithDictionary:liveInfo];
VLiveStreamViewController *liveStreamVC = [[VLiveStreamViewController alloc] initWithNibName:nil bundle:nil];
liveStreamVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
liveStreamVC.fromChatGroup = @(-1);
liveStreamVC.createOption = [createOption copy];
liveStreamVC.joinedGroups = joinedGroups;
liveStreamVC.needSelectGroup = YES;
liveStreamVC.delegate = self;
[self presentViewController:liveStreamVC animated:YES completion:nil];
}
Third:dismiss controller and switch to front controller 第三:解散控制器并切换至前控制器
//YSSJLivingViewController.m
//dismiss之后会响应这个函数 发出一个通知
-(void)viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] postNotificationName:CloseLiveNotification object:nil];
}
//maincontroll.m
//notification's function
-(void)closeLive{
if (_lastSelectedIndex == 2) {
_lastSelectedIndex = _frontSelectedIndex;
[self setSelectedIndex:_frontSelectedIndex];
}else{
_lastSelectedIndex = _frontSelectedIndex;
}
}
Then push a controller and pop it,the wired thing happened..... 然后推一个控制器并弹出它,发生了有线连接.....
Oh,It's solved! 哦,解决了!
After dismissed the controller,i posted a notification to MainController(extend UITabBarController) to switch third item to first item,but the notification's place is error! 解雇控制器后,我向MainController发布了一个通知(扩展UITabBarController)以将第三项切换到第一项,但是通知的位置是错误的!
error place: 错误的地方:
-(void)viewWillAppear:(BOOL)animated{
//...
[[NSNotificationCenter defaultCenter] postNotificationName:CloseLiveNotification object:nil];
//...
}
right place: 正确的位置:
-(void)viewDidAppear:(BOOL)animated{
//...
[[NSNotificationCenter defaultCenter] postNotificationName:CloseLiveNotification object:nil];
//...
}
Then all is work right! 然后一切正常!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.