【问题标题】:Adding time delay to flip animation on navigating view添加时间延迟以在导航视图上翻转动画
【发布时间】:2012-12-26 12:13:20
【问题描述】:

我在导航栏的左侧有一个“过滤器”按钮。单击它时,我希望在切换到下一个视图时具有 1.5 秒的翻转延迟的翻转动画。如何添加代码?

我正在使用这个导航代码:

FilterViewController *vc = [[FilterViewController alloc] init];
vc.delegate = self;

[self.delegate pushViewController:vc  animated:UIViewAnimationTransitionFlipFromLeft];

[vc release];

现在我希望按按钮切换视图时的翻转延迟为 1.5 秒。我已经尝试了一些代码,但它没有给我想要的结果。

【问题讨论】:

  • 使用 NSTimer afterdelay 来延迟动画
  • 我用上面的代码试过了,但是没有用。

标签: objective-c ios uinavigationcontroller


【解决方案1】:

试试这个

    [UIView beginAnimations:@"View Flip" context:nil];
    [UIView setAnimationDuration:1.5];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight 
                           forView:self.navigationController.view cache:NO];

    [self.navigationController pushViewController:vc animated:YES];
    [UIView commitAnimations];

    [vc release];

取自How to do the flip animation between two UIViewControllers while clicking info button?

其他方式:

MainView *nextView = [[MainView alloc] init];
[UIView animateWithDuration:0.75
                         animations:^{
                             [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                             [super pushViewController:nextView animated:NO];
                             [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
                         }];

我从How to change the Push and Pop animations in a navigation based app得到这个

【讨论】:

  • 当你实现这个时会发生什么?
  • 按钮挂起。它甚至没有导航到 nxt 视图。
  • ProjectViewController 可能无法响应 pushViewController .. 收到此警告 .. 仍然无法正常工作
  • 转到我在回答中给出的 SO 的参考线程,有关于这个主题的详细讨论,所以你可能会得到你的答案。万事如意....
  • 我将代码修改为这个... MainView *nextView = [[MainView alloc] init]; [UIView animateWithDuration:0.75 动画:^{ [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [self.delegate pushViewController:nextView Animation:NO]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO]; }]; .. 它现在可以工作了,但动画使导航栏按钮也有动画......
【解决方案2】:

使用它来延迟推送动画:

FilterViewController *vc = [[FilterViewController alloc] init];
vc.delegate = self;
[self performSelector:@selector(callViewController:) withObject:vc afterDelay:1.5];

-(void)callViewController:(FilterViewController*)vc{
    [self.delegate pushViewController:vc  animated:UIViewAnimationTransitionFlipFromLeft];
    [vc release];
}

【讨论】:

  • 我希望当视图翻转时它应该轻松翻转,就像轻松进入,轻松退出......通过添加这个延迟它只是延迟了翻转的时间......任何方法像轻松翻转一样执行翻转...
  • 为此,您应该看到@CRDave 的回答,这就是它的工作原理
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-07-31
  • 2016-03-03
  • 2015-01-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多