Model view controller 模态视图控制器
我在Xcode中使用以下代码在iPhone应用程序的两个视图之间水平翻转Model view controller 模态视图控制器,model-view-controller,flip,Model View Controller,Flip,我在Xcode中使用以下代码在iPhone应用程序的两个视图之间水平翻转 -(IBAction)switchView:(id)sender{ Algorithm2ViewController *Algorithm2ViewControllergo = [[Algorithm2ViewController alloc] initWithNibName:@"Algo
-(IBAction)switchView:(id)sender{
Algorithm2ViewController *Algorithm2ViewControllergo = [[Algorithm2ViewController alloc]
initWithNibName:@"Algorithm2ViewController" bundle:nil];
[UIView beginAnimations:@"flipview" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.view cache:NO];
[self.view addSubview:Algorithm2ViewControllergo.view];
[UIView commitAnimations];
}
在第一次翻转之后,在翻转完成之前,我在背景中获得了一个即将到来的视图的图像。我如何摆脱它?我在第二个视图中找到了这一点添加以下代码
-(IBAction)switchView2:(id)sender{
SecondViewController *SecondViewControllergo = [[SecondViewController alloc]
initWithNibName:@"SecondView"
bundle:nil];
[UIView beginAnimations:@"flipview" context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.view.superview cache:NO];
[self.view addSubview:SecondViewControllergo.view];
[self.view removeFromSuperview];
[UIView commitAnimations];
[SecondViewControllergo release];
}
“从superview中删除”行将删除背景图像