【问题标题】:UINavigationController custom transition animation on Back buttonUINavigationController 自定义后退按钮上的过渡动画
【发布时间】:2011-07-27 22:03:51
【问题描述】:

我在 UINavigationController 中做了一个自定义转换,我使用的代码:

SecondView *newView = [[SecondView alloc] initWithNibName:nil bundle:nil];
[UIView beginAnimtaions:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown];
[self.navigationcontroller pushViewController:newView animated:NO];
[UIView commitAntimations];
[newView release];

但是那个过渡动画只适用于前进,我可以将它应用到后退吗?

谢谢

【问题讨论】:

    标签: objective-c transactions navigationcontroller


    【解决方案1】:

    当然,只需为后退按钮定义一个自定义 UIBarButtonItem 并将其链接到一个自定义方法,该方法执行类似于推送控制器的操作,但您需要弹出视图控制器而不是推送。

    即首先你创建你的后退按钮(在 init 或 viewDidLoad 方法中)

    UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(back)];
    self.navigationItem.leftBarButtonItem = backBarButtonItem;
    [backBarButtonItem release];
    

    然后,在你的 back 方法中,你可以做你的自定义动画

    -(IBAction)back {
    
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration: 1.0];
    
        [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:YES];
    
        [[self navigationController] popViewControllerAnimated:NO];
    
        [UIView commitAnimations];
    
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 2010-11-29
      • 1970-01-01
      • 2013-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多