开发者

Changing UITabBar during Navigation in iOS

When my app launches, it presents a navigation view with a tableview and a tabbar on the bottom.

Something like this:

TabBar --> UINav1, UINav2, UINav3, UINav4

Each UINav contains a ViewController that is eventually displayed.

What I want to be able to do is to change the UITabBar if the user moves from the ListView (Main screen) to the detail view.

I don't have to swap out the whole tabbar atleast change/remov开发者_Go百科e the buttons.

However, if I use the above model (setting TabBarController as the root controller) then it seems it's pretty much stuck and immutable in the course of the navigation. The best I can do is just hide it in certain views.

Been banging my head for like a day trying to figure this out.

Thanks!


You could use

- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated

in your UITabBarController to set the tabBar whatever viewController you wish

EDIT: You might wan't to look at this question wish seems to be quite similar iPhone, how I hide a tab bar button?


It is not very common but you can present a new tab bar controller along with its associated view(s) modally.

Assuming your listView is a UITableViewController, you can push the new tab bar controller in your didSelectRowAtIndexpath method.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// ...
[self.tabBarController presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated]

PS: I would be very careful with how you structure your UI in this case as it can get quite confusing for the user).

I hope it helps. Rog


Upon further research, decided that this was not feasible to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜