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 02-16-2010, 04:56 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 24
Question Navigating my nib/xib files

Afternoon All,

Can anyone see any errors with the code below, it succeeds ok but doesn't show the second nib file, when I click on the button it does nothing...

- (IBAction) EnglishOneButtonPressedid)sender {
EnglishOneViewController *englishOneViewController = [[EnglishOneViewController alloc] initWithNibName:@"EnglishOneViewController" bundle:nil];
[[self navigationController] pushViewController:englishOneViewController animated:YES];
[englishOneViewController release];
}

(apart from the sad face pmsl)
learningCentres is offline   Reply With Quote
Old 02-16-2010, 05:43 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 24
Default

Now I've also tried

- (IBAction)EnglishOneButtonPressedid)sender
{
EnglishOneViewController *englishOneViewController = [[EnglishOneViewController alloc] initWithNibName:@"EnglishOneViewController" bundle:nil];
[self .navigationController pushViewController:englishOneViewController animated:YES];
[englishOneViewController release];
}

but this doesn't work either any idea's?
learningCentres is offline   Reply With Quote
Old 02-16-2010, 06:12 AM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Are you sure the Nib is called "EnglishOneViewController"?
harrytheshark is offline   Reply With Quote
Old 02-16-2010, 06:27 AM   #4 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 24
Default

Quote:
Originally Posted by harrytheshark View Post
Are you sure the Nib is called "EnglishOneViewController"?
Thanks for your reply, Yeah it is definitely named like that Would I need to add anything to EnglishOneViewController.h or .m

Here is the complete RootViewControllers.m

Code:
#import "LearningCentresViewController.h"
#import "EnglishOneViewController.h"

@implementation LearningCentresViewController

- (IBAction)EnglishOneButtonPressed:(id)sender 
{
    EnglishOneViewController *englishOneViewController = [[EnglishOneViewController alloc] initWithNibName:@"EnglishOneViewController" bundle:nil];
    [self .navigationController pushViewController:englishOneViewController animated:YES];
    [englishOneViewController release];
}

- (IBAction)MathsOneButtonPressed:(id)sender 
{
    MathsOneViewController *mathsOneViewController = [[MathsOneViewController alloc] initWithNibName:@"EnglishOneViewController" bundle:nil];
    [self .navigationController pushViewController:mathsOneViewController animated:YES];
    [mathsOneViewController release];
}





/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
	
    [super dealloc];
}
I am aiming to have one main screen which has two buttons one leading to EnglishOneViewController.xib and one going to MathsViewController.xib

Last edited by learningCentres; 02-16-2010 at 06:30 AM.
learningCentres is offline   Reply With Quote
Old 02-16-2010, 06:31 AM   #5 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

In your maths code you need to change the Nib name, but other than that it should be working.

Xcode isn't giving you any warnings or errors?
harrytheshark is offline   Reply With Quote
Old 02-16-2010, 06:38 AM   #6 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 24
Default

Quote:
Originally Posted by harrytheshark View Post
In your maths code you need to change the Nib name, but other than that it should be working.

Xcode isn't giving you any warnings or errors?
Oh yeah, I've done that now... no warnings, no errors nothing? just that nothing happens

I have attached the project because there must be something I'm missing I have re-written the code twice and still can't get it to work!!! ARGHHHH
Attached Files
File Type: zip LearningCentres.zip (29.7 KB, 7 views)
learningCentres is offline   Reply With Quote
Old 02-16-2010, 06:40 AM   #7 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

I see the problem now, you don't have a navigation controller to do the pushing.
harrytheshark is offline   Reply With Quote
Old 02-16-2010, 06:47 AM   #8 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 24
Default

Quote:
Originally Posted by harrytheshark View Post
I see the problem now, you don't have a navigation controller to do the pushing.
Ok I see... What file would I need to code it in? RootViewController?
learningCentres is offline   Reply With Quote
Old 02-16-2010, 06:49 AM   #9 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Yeah, the root view controller
harrytheshark is offline   Reply With Quote
Old 02-16-2010, 06:53 AM   #10 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 24
Default

Quote:
Originally Posted by harrytheshark View Post
Yeah, the root view controller
Would you mind giving me a hint on what code I need? My head hurts from searching...Do I just need to declare the class?
learningCentres is offline   Reply With Quote
Old 02-16-2010, 06:54 AM   #11 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Try creating a new navigation based project, and see what's in that and how it works.
harrytheshark is offline   Reply With Quote
Old 02-16-2010, 07:35 AM   #12 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 24
Default

Quote:
Originally Posted by harrytheshark View Post
Try creating a new navigation based project, and see what's in that and how it works.
Think I've made it worse lol....

Doesn't want to load at all now...

my h file is

Code:
@interface LearningCentresViewController : UIViewController {
	
	UIViewController *navigationController;
	
}

@property (nonatomic, retain) UINavigationController *navigationController;

- (IBAction) EnglishOneButtonPressed:(id)sender;
- (IBAction) MathsOneButtonPressed:(id)sender;

@end
and m is

Code:
//
//  LearningCentresViewController.m
//  LearningCentres
//
//  Created by Charles Marsh on 16/02/2010.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "LearningCentresViewController.h"
#import "EnglishOneViewController.h"
#import "MathsOneViewController.h"

@implementation LearningCentresViewController
@synthesize navigationController;

- (IBAction)EnglishOneButtonPressed:(id)sender 
{
    EnglishOneViewController *englishOneViewController = [[EnglishOneViewController alloc] initWithNibName:@"EnglishOneViewController" bundle:nil];
    [self .navigationController pushViewController:englishOneViewController animated:YES];
    [englishOneViewController release]; 
}

- (IBAction)MathsOneButtonPressed:(id)sender 
{
    MathsOneViewController *mathsOneViewController = [[MathsOneViewController alloc] initWithNibName:@"MathsOneViewController" bundle:nil];
    [self .navigationController pushViewController:mathsOneViewController animated:YES];
    [mathsOneViewController release];
}





/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[navigationController dealloc];
    [super dealloc];
}

@end
I thought I could make UINavigationController into a pointer type of *navigationController - but it now errors saying 'type of property "navigationController" does not match type of iVar "navigationController"???????

Last edited by learningCentres; 02-16-2010 at 07:57 AM.
learningCentres is offline   Reply With Quote
Old 02-17-2010, 03:38 AM   #13 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 24
Default

Can anyone recommend a good tutorial for switching NIB files?
learningCentres is offline   Reply With Quote
Reply

Bookmarks

Tags
multiple, nib, xib

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: 239
16 members and 223 guests
@sandris, ADY, Alsahir, dacapo, Dani77, djohnson, HemiMG, jansan, JasonR, MarkC, mer10, prchn4christ, ryandb2, smethorst, tomtom100
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
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:59 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0