【问题标题】:navigate to new page in iPhone导航到 iPhone 中的新页面
【发布时间】:2012-06-19 10:24:11
【问题描述】:

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

我们将不胜感激!

【问题讨论】:

    标签: iphone animation navigation uibutton buttonclick


    【解决方案1】:
    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];
    

    【讨论】:

    • 老兄,它正在工作,但是当我单击第二页中的后退按钮时,动画应该从右翻转,但它就像popViewController 一样发生。
    • 我应该在哪里写你的 EDIT
    • 但是我的后退按钮不是自定义的,它是导航控制器的一部分,我应该在哪里添加?给我这个答案,我会接受你的回答。
    • lol....如果您想添加额外的代码,您需要对其进行自定义。进行自定义,因为它不会对您的导航控制器造成任何伤害。在 view2 中的该链接中编写代码,然后在弹出之前添加动画。
    【解决方案2】:

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

    你需要这样的东西。

    [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

    【讨论】:

    • 用什么代替 view1 和 view2 ?我想从LicAppViewController 页面导航到PlanPage
    • [LicAppViewController removeFromSuperview]; [self.view addSubview PlanPage]; 当我写这篇文章时,我在第一行收到警告,因为找不到+removefromsuperview 方法,在第二行我收到错误Expected :
    • 你不能删除一个 ViewController 它必须是你要删除的视图所以 LicAppViewController.view
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-02
    • 2021-08-07
    • 1970-01-01
    • 2021-11-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多