I am not using a tab bar or any other control -- I want to basically change the current view to a different view controller dynamically (i.e. via code). I'm not using Interface Builder at all...
For example, let's say we create three view controllers:
(this may not be the best example, but I'm trying to make it simplistic)
View_Hello.m (and .h)
View_Goodbye.m (and .h)
View_Ciao.m (and .h)
Our ViewerAppDelegate would launch View01_Hello.
View_Hello would have a custom touch method that would then need to go to View_Ciao if swiped, but View_Goodbye if just touched.
Any ideas on how I could do this (and please don't say "oh, you need to use xxx interface element for this example". I need to be able to randomly change views based on programatic control within the view of the application I'm working on)
I'm been surfing through Google and StackOverflow for the past week, and gone through my three O'Reilly Cocoa books (plus three iPhone developer books), and all of them just use simple interfaces -- but nothing shows an example like what I'm trying to do.
===========
Edit (@Andrew Grant):
for example:
View_Ciao *viewCiao;
-(void) viewDidLoad {
viewCiao = [[View_Ciao alloc] initWithNibName:@"View_Ciao" bundle:nil];
[viewCiao.view setNeedsDisplay];
[super viewDidLoad];
}
This crashes. :-)
=============
Edit (@Daniel Dickison)
Brilliant -- that worked!
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:viewController.view];
[window makeKeyAndVisible];
// create the second view, remove the first, and then display the second
viewCiao = [[ViewCiao alloc] init];
[viewController.view removeFromSuperview];
[window addSubview:viewCiao.view];
}