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

aaronbastian

macrumors newbie
Original poster
Sep 23, 2010
5
0
Hi,

I am a newbie to the iPhone SDK, but have been teaching myself syntax through youtube tutorials.

Anyway, I am having trouble with a mutiview Window based application, in the simplest loading a view into MainWindow. When I Build and Run, I get no syntax errors, but it loads iPhone sim, and then backs out of the app completely.

I know that there is a simple fix to this that I am not seeing, and I hoped that with the years of experience on this forum that SOMEONE could help a newbie with a simple fix!

My viewDidLoad is coded as follows:
Code:
-(void) viewDidLoad{
	homeClass *home = [[homeClass alloc]initWithNibName:@"home" bundle:nil];
	self.HomeClass = home;
	
	[self.view insertSubview:home.view atIndex:0];
	[home release];
	[super viewDidLoad];
}

any help?
 
When I Build and Run, I get no syntax errors, but it loads iPhone sim, and then backs out of the app completely.
And nothing appears in the Console window? If something abnormal does appear, what does it say? If nothing abnormal, you should probably put in a breakpoint and start stepping through the code until you get to the line it crashes on. Then start to figure out why that line is bad.

Also, although homeClass is a valid class name, the typical convention is to name classes starting with an upper-case to differentiate them from variables, which typically start with a lower-case.
 
the window appears blank for about a second before it backs out. could it be something that i didn't tie in the interface builder?

thanks for the help!!
 
It's giving me no errors, or even warnings. I have currently in the MainWindow.xib, a view controller, and a view. The view controller is tied to the class (switchClass) that has the viewDidLoad method in it. The viewDidLoad method calls home.xib, which has nothing but 6 images and 2 buttons that are supposed to change views again.

I'm stuck, and I'm sure it's a simple fix. Thanks again!
 
It's giving me no errors, or even warnings. I have currently in the MainWindow.xib, a view controller, and a view. The view controller is tied to the class (switchClass) that has the viewDidLoad method in it. The viewDidLoad method calls home.xib, which has nothing but 6 images and 2 buttons that are supposed to change views again.
It's hard to debug descriptions. Please provide some code. Also, if you need to, screencaps of your IB work and connections.
 
My entire switchClass.m:

Code:
#import "switchClass.h"
#import "chetProducts.h"
#import "lolaProducts.h"
#import "chetSearch.h"
#import "lolaSearch.h"
#import "homeClass.h"


@implementation switchClass
@synthesize ChetProducts;
@synthesize LolaProducts;
@synthesize ChetSearch;
@synthesize LolaSearch;
@synthesize HomeClass;

-(void) viewDidLoad{
	homeClass *home = [[homeClass alloc]initWithNibName:@"home" bundle:nil];
	self.HomeClass = home;
	
	[self.view insertSubview:home.view atIndex:0];
	[home release];
	[super viewDidLoad];
}

-(IBAction) lolaButton: (id)sender{
	lolaProducts *lola = [[lolaProducts alloc]initWithNibName:@"lolaProducts" bundle:nil];
	self.LolaProducts = lola;
	
	[self.view insertSubview:lola.view atIndex:0];
	[lola release];
	[super viewDidLoad];
}

-(IBAction) chetButton: (id)sender{
	chetProducts *chet = [[chetProducts alloc]initWithNibName:@"chetProducts" bundle:nil];
	self.ChetProducts = chet;

	[self.view insertSubview:chet.view atIndex:0];
	[chet release];
	[super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

- (void)viewDidUnload {
    [super viewDidUnload];
}


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


@end

Please correct me if I am wrong; I have a different class for each xib file, a different class for each screen developed thus far.

my MainWindow.xib looks like this:
http://www.facebook.com/photo.php?pid=5660154&l=4b1f28fbed&id=506231875


For a better look at the connections:
http://www.facebook.com/photo.php?pid=5660245&l=ec3789f48b&id=506231875

my home.xib looks like this:
http://www.facebook.com/photo.php?pid=5660155&l=3f89ec8878&id=506231875
 
Hmm, so as far as I can tell, you've shown us how you are trying to load the "home" view into switchClass. But you haven't shown us how you are adding switchClass's view into MainWindow's.
 
I have loaded into the View Controller into MainWindow.xib, and then set its class as switchClass. This is all that I have done in IB with the MainWindow. What did I miss?
 
I have loaded into the View Controller into MainWindow.xib, and then set its class as switchClass. This is all that I have done in IB with the MainWindow. What did I miss?
I think you're missing the part where you actually have MainWindow display the view for switchClass. I'm curious: where have you learned this particular technique? Perhaps now would be a good time to step back from the real coding and learn some more about View Programming for iOS.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.