views:

157

answers:

0

Hey guys just a quick question:

Overview:

I have a basic magazine app, it has multiple view controllers, who have 2 views each. one landscape and one portrait view for visual reasons.

The app delegate has all the actions in it. These are called from the view controllers using :

The_Ride_Vol_1AppDelegate *mainDelegate = (The_Ride_Vol_1AppDelegate *)[[UIApplication sharedApplication] delegate];
[mainDelegate fliptop2];

what i want is when a selected button is clicked it loads a new view and dismisses the modal view. This way i can cycle through pages.

I thought i did this by calling the view controllers from the delgate but i still get memory warning 1 and then 2. Here is my action to call the new xib and unload the current view, where a i going wrong?

Here is the button to go forward

- (void)fliptop1{

    p1 *aSecondView = [[p1 alloc] initWithNibName:@"p1" bundle:nil ];
    [self setP1ViewController:aSecondView ];
    [aSecondView release];
    p1ViewController.view.alpha = 0;
    [UIView beginAnimations:nil context:NULL ];
    [UIView setAnimationDuration:0.5];
    viewController.view.alpha =0;
    p1ViewController.view.alpha = 1;
    [UIView commitAnimations];
    [viewController.view removeFromSuperview ];

    [self.window addSubview:[p1ViewController view] ];

}

Here is the button back

- (void)flipback2 {
    The_Ride_Vol_1ViewController *aSecondView = [[The_Ride_Vol_1ViewController alloc] initWithNibName:@"The_Ride_Vol_1ViewController" bundle:nil];
    [self setViewController:aSecondView];
    [aSecondView release];
    viewController.view.alpha = 0;
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    p1ViewController.view.alpha =0;
    viewController.view.alpha = 1;
    [UIView commitAnimations];  
    [p1ViewController.view removeFromSuperview];
    [self.window addSubview:[viewController view]];
}

Cheers