PresentModalViewController或addsubview?

use*_*733 5 views flip addsubview presentmodalviewcontroller

嗨,我正在xcode 3.2.3中编写应用程序.我想做的就是切换到另一个视图,但我不确定最好的方法.我可以用这两种方式做到这一点......

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

screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentModalViewController:screen animated:YES];

[screen release];
Run Code Online (Sandbox Code Playgroud)

或使用......

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];
Run Code Online (Sandbox Code Playgroud)

我对这两种方法都有一些问题.如果我使用presentModalViewController并在PreferencesViewController中模拟内存警告我的应用程序崩溃.第二种方法不是这种情况.然而,第二种方法使我的按钮在翻转动画期间看起来很奇怪.

有人可以告诉我什么是错的和/或建议我哪种方法是正确的.

谢谢

小智 0

你可以尝试这样做,别忘了释放:

[self.navigationController pushViewController:[[YourViewController alloc]    initWithNibName:nil bundle:nil] animated:YES];   
Run Code Online (Sandbox Code Playgroud)