Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cindori

macrumors 68040
Original poster
Jan 17, 2008
3,527
378
Sweden
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:

6dgfz.jpg
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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.
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
Like ROBBIEDUNCAN said.
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
 

Cindori

macrumors 68040
Original poster
Jan 17, 2008
3,527
378
Sweden
So now I have

My MainWindow and AppDelegate
This contains the navigation controller

lmxk9.jpg



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

w5343.jpg



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

u4vpn.jpg





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

So in ScheduleViewController.m I have this code:

nn4yp.jpg



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?

EDIT:

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


tnr61.jpg


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?

 
Last edited:

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
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
Code:
 - (IBAction) goBack:(id) sender {
 [self.navigationController popViewControllerAnimated:YES];
}

have fun.
 

Cindori

macrumors 68040
Original poster
Jan 17, 2008
3,527
378
Sweden
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.

tutorial:
http://broadcast.oreilly.com/2009/06/tab-bars-and-navigation-bars-t.html
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.