2016-07-25 4 views
0

質問:私はUITabBarControllerを使用していますが、すべてOKです。しかし、アイテムを選択した後、コントローラをコントローラに表示し、現在のコントローラを破棄して最初のアイテムに戻すと、有線のものが発生しました。UITabBarControllerのtabBarがコントローラのビューよりも遅かった

1.コントローラをプッシュしました)

2.popの上部のコントローラー、tabBarは、最初のコントローラーのビューが表示され、animation.itのワイヤリングされた後に表示されます。

通常のステータスはtaborで、最初のbarItemの最初のコントローラのビューと共に表示されます。

私は何をすればよいですか?

ありがとうございました!

マイコードはここにある:

まず:初期thirdNavとは

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

第二tabbaritem:ThirdNavのルートコントローラ //YSSJLivingViewController.m から新しいコントローラを発表 - (無効)p_jumpToLivePage { NSDictionary * options = @ { @ "gid":@( - 1)、 @ "gids":@ []、 @ "shortContent":@ ""、 @ "タグ":@ []、 @ "title":@ ""、 @ "type":@ "live" }; 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

ああ、それは解決しています!

コントローラを終了した後、私はMainController(UITabBarControllerを拡張)に通知して、3番目の項目を最初の項目に切り替えましたが、通知の場所はエラーです!

エラー場所:

-(void)viewWillAppear:(BOOL)animated{ 
    //... 
    [[NSNotificationCenter defaultCenter] postNotificationName:CloseLiveNotification object:nil]; 
    //... 
} 

正しい場所:

-(void)viewDidAppear:(BOOL)animated{ 
    //... 
    [[NSNotificationCenter defaultCenter] postNotificationName:CloseLiveNotification object:nil]; 
    //... 
} 

その後、すべてが正しく動作しています!

関連する問題