0

我是 iPhone 开发者的新手,

单击按钮时,我想使用此动画导航到新页面,UIViewAnimationTransitionFlipFromLeft

我该怎么做?

  -(void)btnClick{

        [UIView beginAnimations:nil context:nil]; 
        [UIView setAnimationDuration:0.7]; 
        [UIView setAnimationBeginsFromCurrentState:YES]; 
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO]; 

        [UIView commitAnimations];

}

当我点击 btn 动画发生但我无法导航到新页面。

任何帮助将不胜感激!

4

2 回答 2

4
ViewController *viewController = [[ViewController alloc]initWithNibName:@"View" bundle:nil];
[UIView beginAnimations:@"Flip" context:nil]; 
    [UIView setAnimationDuration:0.7]; 
    [UIView setAnimationCurve:UIViewAnimationOptionCurveEaseInOut]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO]; 
[self.navigationController pushViewController:viewController animated:YES];
    [UIView commitAnimations];
[viewController release];

viewController 是您要导航到的页面。

流行音乐:

    [UIView  beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
于 2012-06-19T10:31:49.307 回答
3

您没有指定要换入和换出的视图。目前,您只是在设置动画发生的位置以及它是什么类型的动画。

你需要这样的东西。

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:0.7]; 
[UIView setAnimationBeginsFromCurrentState:YES]; 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO]; 
[view1 removeFromSuperview];
[self.view addSubview view2];
[UIView commitAnimations];

我建议阅读此文档,因为我认为您并不完全理解ViewControllerandView关系。ViewControllers个人之间有不同的过渡方式views

就在使用这种方法的情况下,你view1LicAppViewController.view假设你PlanPage是一个视图,那么view2就是PlanPage.

于 2012-06-19T10:27:23.520 回答