objective c - switch for a TabBarView without StoryBoard -
i have connectionviewcontroller , when click on test button, switch tabviewcontroller.
in connectionviewcontroller :
- (ibaction)testbutton:(id)sender { tabbarviewcontroller *tabbarviewcontroller = [[tabbarviewcontroller alloc] init]; [self presentviewcontroller:tabbarviewcontroller animated:yes completion:nil]; }
but when click on test button, tabbarview black, without anything.
what fix ? modal segue, not push.
thx lot
[edit] : solution create custom segue class customsegue.m method :
-(void) perform { connectionviewcontroller *src = (connectionviewcontroller*) self.sourceviewcontroller; tabbarviewcontroller *dest = (tabbarviewcontroller*) self.destinationviewcontroller; [uiview transitionwithview:src.navigationcontroller.view duration:0.2 options:uiviewanimationoptiontransitionflipfromleft animations:^{ [src presentviewcontroller:dest animated:yes completion:null]; } completion:null]; }
the reason why tab bar controller black not have viewcontrollers present. need set tabbarcontroller.viewcontrollers property before present it. lets want present tabbarviewcontroller viewcontroller1 on first tab , viewcontroller2 on second tab.
tabbarviewcontroller.viewcontrollers = @[viewcontroller1, viewcontroller2];
Comments
Post a Comment