iPhone Developer Help

Full Version: Changing views
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi. i want to write a very simple application.

if a button on the first screen is pressed, i want to go to the 2nd screen.

right now, i have a controller for each screen/view. in my delegate i have [window addSubview:controllersView]; for the first view.

so when the button is pressed, the communication should happen as follows:
firstView --> firstViewController --> delegate

the delegate's window should be told to add the 2nd controller's view to the vier hierarchy. but right now, when i press the button - the view does not change.

can anyone provide any help? thanks.
Can you post code...? it will help...to give ideas...
ok in my AppDelegate.m i've got

FirstViewController *aFirstViewController = [[FirstViewController alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]];
self.myFirstViewController = aFirstViewController;
[aFirstViewController release];

controllersView = [myFirstViewController view];
[window addSubview:controllersView];

in the applicationDidFinishLaunching: routine.

now i've got 2 controllers, FirstViewController and SecondViewController.

FirstViewController manges a subclassed UIView. i implement touch detection, and if i touch a certain area of the screen, i want to switch the screen to SecondViewController's view.

i've got no problems with touch detection, but switch between views is where i'm stuck. thanks.
In AppDelegate.m

dont use
FirstViewController *aFirstViewController = [[FirstViewController alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]];

use UINavigationController and in interface builder set that class name as "FirstViewController"......
i've got a problem:

Code:
TableViewController *aTableViewController = [[TableViewController alloc] init];
  self.myTableViewController = aTableViewController;
  [aTableViewController release];
  
  navigationController = [[UINavigationController alloc] initWithRootViewController:myTableViewController];
  [window addSubview: navigationController.view];
    [window makeKeyAndVisible];


works. but i no longer programmatically make my views. instead i use

Code:
TableViewController *aTableViewController = [[TableViewController alloc] initWithNibName:@"TableView" bundle:[NSBundle mainBundle]];


but this causes the program to crash.

Reference URL's