I've been bashing my head over views the past couple of days. I don't want set up navigation controller or tab bar controller, I simply want to create a very basic view based application.
Screen 1 loads, says "Intro screen" with a button that allows you to go to screen 2 (Create Account Screen). Right now with this code, it works. Since I'm using initWithNibName I understand that I would want to override the viewdidload function. I didn't do this, however it still displays, but I have a feeling this isn't what I want in the long run for a larger scale program with many screens.
My question is this: If I'm not mistaken, when I used self.view addSubview, all this does is after the view is created is push the new view to the front of the other views. If I eventually have a lot of screens, I don't want to have 10+ views loaded in the background as this would kill the memory.
When I was reading around, I keep seeing the documentation mentioning removeFromSuperview. I threw in [self.view removeFromSuperview] right before [self.view addSubview:createAccount....] however obviously that doesn't work, and it removes the view entirely and then has nothing to display the new view on.
What's the proper way to release the current screen I'm viewing in exchange for pushing the new view onto the stack? How do I call the current view only for the screen I'm currently viewing? Is the only way to do this by creating one master root view controller that has ALL of the ibactions for each of the buttons and then controlling everything through this?
Thanks in advance for the help.
Screen 1 loads, says "Intro screen" with a button that allows you to go to screen 2 (Create Account Screen). Right now with this code, it works. Since I'm using initWithNibName I understand that I would want to override the viewdidload function. I didn't do this, however it still displays, but I have a feeling this isn't what I want in the long run for a larger scale program with many screens.
My question is this: If I'm not mistaken, when I used self.view addSubview, all this does is after the view is created is push the new view to the front of the other views. If I eventually have a lot of screens, I don't want to have 10+ views loaded in the background as this would kill the memory.
When I was reading around, I keep seeing the documentation mentioning removeFromSuperview. I threw in [self.view removeFromSuperview] right before [self.view addSubview:createAccount....] however obviously that doesn't work, and it removes the view entirely and then has nothing to display the new view on.
What's the proper way to release the current screen I'm viewing in exchange for pushing the new view onto the stack? How do I call the current view only for the screen I'm currently viewing? Is the only way to do this by creating one master root view controller that has ALL of the ibactions for each of the buttons and then controlling everything through this?
Thanks in advance for the help.
Code:
-(IBAction)goToCreateAccountView:(id)sender
{
if (self.createAccountViewController == nil)
{
CreateAccountViewController *createAccountController = [[CreateAccountViewController alloc] initWithNibName:@"CreateAccountView" bundle:nil];
self.createAccountViewController = createAccountController;
[createAccountController release];
NSLog(@"View loaded.");
}
[self.view addSubview:createAccountViewController.view];
}