I add a firstView in the AppDelegate :
#import "TestViewAppDelegate.h"
#import "MainViewController.h"
@implementation TestViewAppDelegate
@synthesize window;
@synthesize mainViewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];
self.mainViewController = aController;
[aController release];
self.mainViewController.view.frame = [UIScreen mainScreen].applicationFrame;
[window makeKeyAndVisible];
[window addSubview:mainViewController.view];
}
- (void)dealloc {
[mainViewController release];
[window release];
[super dealloc];
}
Then I want to switch to the secondView :
#import "MainViewController.h"
#import "SecondViewController.h"
@implementation MainViewController
@synthesize mainViewController, secondViewController;
- (IBAction)viewSwitch
{
SecondViewController *second = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil];
self.secondViewController = second;
[second release];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[mainViewController.view removeFromSuperview];
[self.view addSubview:secondViewController.view];
[UIView commitAnimations];
}
- (void)dealloc {
[mainViewController release];
[secondViewController release];
[super dealloc];
}
@end
And then the same thing for switching from secondView to firstView…
The problem is when I switch the view I thought to release is always visible and don't disappear.