Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-25-2009, 09:50 AM   #1 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 47
Default Unload subview/revert to previous view

Hey!

Im trying to implement a standard hierarchical menu, and I've actually got it working to the point where it compiles and I can pick an entry and the appropriate subview loads. What I can't figure out is how to make it so I can return to the menu from the subviews.

What I've done is this:

Code:
- (IBAction)loadFoo:(id)sender {
	if (self.fooViewController == nil) {
		FooViewController *aFooViewController = [[FooViewController alloc] initWithNibName:@"FooView" bundle:nil];
		self.fooViewController = aFooController;
		[aFooController release];
	}

	BarAppDelegate *appDelegate = (BarAppDelegate *)[[UIApplication sharedApplication] delegate];
	BarViewController *viewController = (BarViewController *)[appDelegate viewController];
	UIWindow *window = (UIWindow *)[appDelegate window];

	[viewController.view removeFromSuperview];
	[window addSubview:fooViewController.view];
}
Now I tried to essentially do the reverse of this and pretty soon ended up in cyclical dependencies territory with some really cryptic errors. I also tried flattening out the hierarchy so that the menu was essentially just another choice that happened to be loaded automatically, but then I ended up in the same place as before with the added problem of having to kick every decision up a level. So, am I going about this in a really boneheaded way? It *feels* like something that should be trivial enough to implement...
royen is offline   Reply With Quote
Old 11-25-2009, 10:53 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 47
Default

Never mind, I over-complicated stuff. Works fine with just

Code:
[self.view removeFromSuperview];
royen is offline   Reply With Quote
Old 11-25-2009, 10:53 AM   #3 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,129
Default

Any reason you aren't using a navigation controller?
__________________
BriTer Ideas LLC - Code review, consulting, development. PM for pricing.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
BrianSlick is offline   Reply With Quote
Old 11-25-2009, 11:14 AM   #4 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 47
Default

Quote:
Originally Posted by BrianSlick View Post
Any reason you aren't using a navigation controller?
Ignorance -- dind't know they existed until you just mentioned them

Will definitely read up on them now!
royen is offline   Reply With Quote
Reply

Bookmarks

Tags
subview, view

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 248
17 members and 231 guests
ADY, Alsahir, Dani77, Desert Diva, Duncan C, F_Bryant, Grinarn, HemiMG, Herbie, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, smethorst, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,761
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:43 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0