View Full Version : Replacing a tab view with a new view

May 8, 2011, 03:09 PM
I have a tab view set up and working fine, with individual controllers for the views.

However, in one of the views, I want a button that is going to load a new view.

But! This view should not just replace the view of the tab. It should replace everything in the window, making the tab bar itself disappear.

I believe this is supposed to be achieved by UINavigationController in some way.

I started learning iPhone developing yesterday, so noobdetails are appreciated.

An illustration of what I want to achieve:


May 8, 2011, 03:10 PM
You could use a UINavigationController. If you do that it has to be the root view controller. Or you could present the new view controller modally. The documentation will give you details on either.

May 9, 2011, 04:04 AM
In the mainwindow u have couple of "View Controllers", inside the Tab Bar Controller, drag a Navigation Controller from ur library, insert it, and use that.
U can use [self.navigationController pushViewController:pointerToUIViewController animated:YES];

Then it should do EXACTLY like u want ;p
Or do a modal transition style, if it's just for displayin info or w/e

SO many options ;p

May 9, 2011, 09:32 AM
So now I have

My MainWindow and AppDelegate
This contains the navigation controller


ScheduleView - this is supposed to be view 2 of my navigation, and is illustrated in the original post right image (the "a new view")


TabViewController - this is supposed to be view 2 of my navigation, and is illustrated in the original post left image


And now I want that "Tillbaka" (Backwards) - button in ScheduleView to load the TabViewController view...

So in ScheduleViewController.m I have this code:


As you can see in the first image, I load my main window view from "ScheduleView"

But when I press the Tillbaka-button, I get:

Application tried to push a nil view controller on target <UINavigationController: 0x4b15a30>.

What am I missing?


aha, so I changed the button action a little bit:


and now I get a view atleast, although it's all white

gonna see if Im missing something in TabViewController

Edit 2

Still having problems, I don't get why my view and tab controller are separate from each other?

http://piclair.com/data/qevsk.jpg (http://piclair.com/qevsk)

May 10, 2011, 03:01 AM
Not completely sure if u made it switch to the second view like Robbie/me suggested.
If that worked, and u just want a back button u can do it like this
- (IBAction) goBack:(id) sender {
[self.navigationController popViewControllerAnimated:YES];

have fun.

May 14, 2011, 10:31 AM
I figured it out.

What I did wrong was trying to have a NavigationView encapsule a TabView, because I wanted to get rid of the TabBar when I switched NavigationView.

However the correct way was to have a TabView encapsule a NavigationView, and then on switching to a new NavigationView, to set

self.hidesBottomBarWhenPushed = YES;

and then set it to NO when I switched back.