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 12-04-2009, 04:53 PM   #1 (permalink)
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
Default adding UINavigationController to FlipsideViewController of Utility application

I'd like to be able to have the user tap a button on the flipsideViewController of a Utility template application. This would then have the device push another view controller. Using Interface Builder, I've tried adding a UINavigationController in the FlipsideView.xib, but that doesn't feel like the right place for it. I've also tried adding it to MainWindow.xib, but I couldn't figure out how to link that to the FlipsideViewController. I've also just tried doing it simply in code like this:

Code:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // In FlipSideViewController.h: 	UINavigationController *navigationController;
		self.navigationController = [[UINavigationController alloc] initWithRootViewController:self];
		[self.view addSubview:navigationController.view];
		NSLog( @"Added subview" );
    }
    return self;
}
but that causes it to crash when I tap the info button despite the fact that "Added subview" is displayed on the debugger console. What would be the recommended way of doing this? A push in the right direction would be great at this point... I've wasted an entire evening trying to figure this out. Thanks!
__________________
German Course: Learn German anywhere! Chess Player: Study Chess anywhere!
chuck is offline   Reply With Quote
Old 12-06-2009, 06:07 AM   #2 (permalink)
iPhone App Developer
 
chbeer's Avatar
 
Join Date: Sep 2008
Location: Berlin, Germany
Posts: 229
Default

You are extending initWithNibName which is called when the view is loaded from a NIB-file. It would be IMO better to add the navigation controller in the NIB file.
__________________
Learn vocabularies on iPhone? iVocabulary!
chbeer is offline   Reply With Quote
Old 12-06-2009, 06:21 AM   #3 (permalink)
ole
Registered Member
 
ole's Avatar
 
Join Date: Dec 2009
Location: Berlin
Posts: 14
Default

If I understand you correctly, you should change -showInfo in MainViewController.m to this:

Code:
- (IBAction)showInfo {    
	
    FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
    controller.delegate = self;
    controller.title = @"Flipside";
    
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
    navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:navController animated:YES];
	
    [navController release];
    [controller release];
}
This makes a navigation controller the main flipside controller. Now, in FlipsideViewController, you can add a button and push a new controller from its action method:

Code:
- (IBAction)pushNextLevel {
    UIViewController *controller = [[UIViewController alloc] initWithNibName:nil bundle:nil];
    controller.title = @"Blank View Controller";
    [self.navigationController pushViewController:controller animated:YES];
    [controller release];
}
ole is offline   Reply With Quote
Old 12-06-2009, 07:40 AM   #4 (permalink)
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
Default

Thanks Ole! That worked... thanks so much!!
__________________
German Course: Learn German anywhere! Chess Player: Study Chess anywhere!
chuck is offline   Reply With Quote
Old 03-09-2010, 07:10 AM   #5 (permalink)
Registered Member
 
eludens's Avatar
 
Join Date: Jan 2009
Location: Madrid, Spain
Posts: 7
Default

It has been very useful for me as well! Great stuff! Thank you Ole!
__________________
iPhone App: RAEútil.
eludens is offline   Reply With Quote
Old 03-16-2010, 05:53 AM   #6 (permalink)
Registered Member
 
digidan's Avatar
 
Join Date: Aug 2009
Location: St. Albans, Hertfordshire, UK
Posts: 83
Default

Thanks!

How would you go about adding a table view to the navigation controller using this method?
__________________
Nazi Zombies Soundboard v1.2 - Call Of Duty: World At War Nazi Zombie Soundboard for iPhone + iPad!

YellowCar - As featured on the App Store!

iSickNote v1.1 - now includes Twitter update PLUS 200+ SickNotes!!

EngineAdmin v1.1.3 - For use with Telestream's Episode Engine
digidan is offline   Reply With Quote
Reply

Bookmarks

Tags
flipsideviewcontroller, uinavigationcontroller, utility

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: 260
17 members and 243 guests
14DEV, @sandris, ADY, ArtieFufkin10, bookesp, ckgni, Dani77, DarkAn, HemiMG, iDifferent, jakerocheleau, JasonR, prchn4christ, Rudy, Speed, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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