【问题标题】:Animate UINavigationController transition with blocks使用块动画 UINavigationController 过渡
【发布时间】:2012-05-24 12:25:54
【问题描述】:

谁能告诉下面这段代码 sn-p 的块动画等效?

[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight 
           forView:self.navigationController.view cache:NO];

NextViewController *next = [[NextViewController alloc] 
           initWithNibName:@"NextViewController" bundle:nil];

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

【问题讨论】:

    标签: iphone objective-c ios xcode objective-c-blocks


    【解决方案1】:
    NextViewController *next = [[NextViewController alloc] initWithNibName:@"NextViewController" bundle:nil];
    
    [UIView transitionWithView:self.navigationController.view 
                      duration:0.75 
                       options:UIViewAnimationOptionTransitionFlipFromRight 
                    animations:^{
                     [self.navigationController pushViewController:next animated:NO];
                    } 
                    completion:nil];
    

    【讨论】:

    • 比我在堆栈上看到的其他一些方法更容易解决这个问题。谢谢
    【解决方案2】:
    UIView: + (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多