arpit arpit - 5 months ago 25
iOS Question

tabbar is not displaying in secondview controller

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 .

Answer

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.

This might be the implementation you are looking for TabBarVC inside NavC

Comments