views:

30

answers:

0

Hey guys just a quick question:

I have an app, it has multiple view controllers, who have 2 views each. one for portrait and one landscape.

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

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 controller and dismisses the current view controller. I thought i did this by calling the actions from the delegate but i still get memory warning and error.

Here is my action to call the new xib and unload the current view, where am i going wrong?

Here is the button to go forward (next page)

- (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]];
}