导航到iPhone中的新页面

时间:2012-06-19 10:24:12

标签: iphone animation navigation uibutton buttonclick

我是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动画时,我无法导航到新页面。

任何帮助都会受到欢迎!

2 个答案:

答案 0 :(得分: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];

答案 1 :(得分: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];

我建议您阅读此文档,因为我不认为您完全理解ViewControllerView关系。在ViewControllers和个人views之间有不同的转换方式。

如果您使用此方法,则view1将为LicAppViewController.view,并假设您PlanPage为视图,则view2仅为PlanPage。< / p>