5

Hi I am writing an app in xcode 3.2.3. All I want to do is switch to another view but I am unsure of the best way to do this. I can do it either of these 2 ways...

PreferencesViewController *screen = [[PreferencesViewController alloc]initWithNibName:nil bundle:nil];

screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentModalViewController:screen animated:YES];

[screen release];

or using...

PreferencesViewController *screen = [[PreferencesViewController alloc]initWithNibName:nil bundle:nil];

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:1.0];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];

[self.view addSubview:screen.view]; 

[UIView commitAnimations];

I have some problems with both of these methods. If I use presentModalViewController and I simulate a memory warning in the PreferencesViewController my app crashes. This is not the case with the second method. The second method however makes my buttons looks strange during the flipping animation.

Can someone tell me what is wrong and/or advise me on which method is right.

Thanks

user157733
  • 569
  • 2
  • 12
  • 26

2 Answers2

0

You can try to do this, don't forget to release:

[self.navigationController pushViewController:[[YourViewController alloc]    initWithNibName:nil bundle:nil] animated:YES];   
Marko
  • 20,385
  • 13
  • 48
  • 64
avernon2
  • 31
  • 6
0

PresentModalViewController:-

YourViewController *vC = [YourViewController alloc]initWithNibName:@"YourViewController" bundle:nil];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:vC animated:YES];
[vC release];

This is working fine for me

Try this code.All the best

iOSiOS
  • 214
  • 2
  • 5
  • 10