I am new in iOS world.I am creating one tab-bar sample app.
There is one button in first view-controller when i click this button it goes to to second view-controller.In second view-controller i use one gridview
and i left 100 space at bottom.
now in second view-controller i have to add one tab bar so i go to Editor->Embedin->Tabbar controller
and run application but i do not see tab bar here.I also try to use tab bar controller on object library but same issue i found.
Why tab bar is not displaying in second view-controller.Any suggestion ?
button click event :-
SecondVC *vc=[self.storyboard instantiateViewControllerWithIdentifier:@"SecondVC"];
[self.navigationController pushViewController:vc animated:YES];
Thanks .
If you have the SecondVC embedded in a TabBarVC you need to present the TBVC instead of the SecondVC in order for the Tab Bar to actually appear.
So instead of doing:
SecondVC *vc=[self.storyboard instantiateViewControllerWithIdentifier:@"SecondVC"];
[self.navigationController pushViewController:vc animated:YES];
you need to do:
TabBarVC *vc=[self.storyboard instantiateViewControllerWithIdentifier:@"TabBarVC"];
[self.navigationController pushViewController:vc animated:YES];
This will add to the navigation stack the Tab Bar View Controller.
Button to viewcontroller SecondVC set segue identifer name as Pass
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{if ([[segue identifier] isEqualToString:@"Pass"])
{
SecondVC* vc = [[SecondVC alloc] init];
vc = (SecondVC ) [[(UINavigationController )[[self.tabBarController viewControllers] objectAtIndex:0] viewControllers] objectAtIndex:0];
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.