简体   繁体   English

UITabBarController的tabBar显示的速度比控制器的视图慢

[英]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.

相关问题 从UIViewController导航到UITabbarController,然后从Tabbar导航到另一个View Controller - Navigate from UIViewController to UITabbarController and than Tabbar to Another View Controller 搜索到标签栏和导航栏中的视图控制器 - Segue to a view controller that's within a tabbar and navbar IphoneX View隐藏在Tabbar控制器的Tabbar旁边 - IphoneX View hidden beside the Tabbar controller's tabbar UITabBarController的TabBar项目标题在Xib中不可见 - UITabBarController's TabBar items title are not visible in Xib 在 UITabBarController 的 tabBar 前面显示 ViewController 并隐藏这个 tabBar - Present ViewController in front of UITabBarController's tabBar and hide this tabBar 如何在iOS中为UITabBarController的更多视图控制器设置selectedindex - How to set selectedindex for UITabBarController's More view controller in iOS 使用UITabBarController将UISlider数据从XIB的视图控制器传递到非XIB的视图控制器 - Passing UISlider Data From a XIB's View Controller to Non-XIB's View Controller With UITabBarController 如何将对象从视图传递到嵌入在作为容器视图的Tabbar控制器中的Navigationcontroller中的视图? - How to pass an object from a view to a view that's embedded in a Navigationcontroller that's embedded in a Tabbar controller that's a container view? 返回导航控制器在TabBar应用程序中的第一个视图 - Back to Navigation Controller's first view in TabBar app 访问UITabBarController的内容视图 - Accessing UITabBarController's content view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM