问题:我正在使用UITabBarController,一切正常。但是,当我选择一个项目,然后在项目的控制器中显示一个控制器,在解除当前控制器后,然后回到第一个项目,有线事情发生了:
1.推动控制器(一切正常)
2.pop顶部的控制器,tabBar显示在第一个控制器的视图显示并且带有animation.it的有线。正常状态是tabor应该与第一个barItem的第一个控制器视图一起显示。
任何人都知道我该怎么做?
谢谢高级!
我的代码在这里:
首先:初始的thirdNav和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];
第二:从ThirdNav的根控制器中提供一个新的控制器 //YSSJLivingViewController.m - (无效)p_jumpToLivePage { NSDictionary * options = @ { @" GID" :@( - 1), @" GID的" :@ [], @" shortContent" :@"", @"标记" :@ [], @"标题" :@"", @"类型" :@"直播" }; 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];
}
第三:关闭控制器并切换到前端控制器
//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;
}
}
然后按下一个控制器并弹出它,有线的事情发生了......
答案 0 :(得分:0)
哦,它已经解决了!
在解除控制器后,我向MainController发布了一个通知(扩展UITabBarController),将第三项切换到第一项,但通知的位置是错误的!
错误地点:
-(void)viewWillAppear:(BOOL)animated{
//...
[[NSNotificationCenter defaultCenter] postNotificationName:CloseLiveNotification object:nil];
//...
}
正确的地方:
-(void)viewDidAppear:(BOOL)animated{
//...
[[NSNotificationCenter defaultCenter] postNotificationName:CloseLiveNotification object:nil];
//...
}
然后一切正常!