2016-07-25 13 views
0

Frage: Ich benutze UITabBarController und alles ist in Ordnung. Allerdings, wenn ich ein Element ausgewählt, dann einen Controller in der Steuerung des Artikels präsentieren, nach dem Ablehnen des aktuellen Controllers und zurück zum ersten Element, die Sache mit Kabel passiert ist:UITabBarController TabBar zeigte langsamer als Controller Ansicht

1.Pushed einen Controller (alles ist in Ordnung)

2.Pop der Controller von oben, die TabBar zeigte nach der ersten Controller-Ansicht gezeigt und mit animation.it ist verdrahtet.

Der normale Status ist tabor sollte zusammen mit der ersten Controller-Ansicht des ersten barItems angezeigt werden.

Wer weiß, was soll ich tun?

Vielen Dank!

My-Code ist hier:

Erstens: Anfangs thirdNav und 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]; 

Zweitens: präsentieren einen neuen Controller von ThirdNav Root-Controller //YSSJLivingViewController.m - (void) {p_jumpToLivePage NSDictionary * Optionen = @ { @ "gid": @ (- 1), @ "gids": @ [], @ "shortContent": @ "", @ "Tags": @ [], @ "title": @ "", @ "type": @ "live" }; NSMutableDictionary * liveInfo = [[NSMutableDictionary-Zuweisung] initWithDictionary: Optionen];

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

Drittens: Controller entlassen und

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

Dann einen Controller drücken und Pop es Front-Controller wechseln, wird das verdrahtete Sache passiert .....

Antwort

0

Oh, es ist gelöst!

Nachdem ich den Controller entlassen habe, habe ich eine Benachrichtigung an MainController (extend UITabBarController) gepostet, um das dritte Element zum ersten Element zu wechseln, aber der Ort der Benachrichtigung ist ein Fehler!

error Ort:

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

richtigen Ort:

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

Dann ist alles in Ordnung arbeiten!

Verwandte Themen