【问题标题】:UINavigation Bar not visible in animation of custom unwind segueUINavigation Bar 在自定义展开 segue 的动画中不可见
【发布时间】:2014-08-11 12:07:53
【问题描述】:

我在导航控制器中使用自定义展开转场,在转场动画中,导航栏在动画期间不可见,当动画结束时导航栏“弹出”。 ¿如何在动画期间保持导航栏的可见性?

更多细节:

我在导航栏中有一个按钮调用模态视图这个动画按预期执行,新视图有一个按钮来触发展开segue动画视图增长和消失,而这个动画正在执行导航栏在动画完成之前,目标视图控制器不可见。

这是我用于自定义 segue 的代码。

- (void) perform {
    UIViewController *sourceViewcontroller  = self.sourceViewController;
    UIViewController *destinationViewcontroller = self.destinationViewController;

    [sourceViewcontroller.view.superview insertSubview:destinationViewcontroller.view atIndex:0];

    [destinoViewcontroller beginAppearanceTransition:YES animated:YES];

    [UIView animateWithDuration:0.2
                          delay:0.0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         origenViewcontroller.view.transform = CGAffineTransformMakeScale(1.5, 1.5);
                         origenViewcontroller.view.alpha = 0.0;
                     }
                     completion:^(BOOL finished){
                         [destinationViewcontroller.view removeFromSuperview];
                         [sourceViewcontroller dismissViewControllerAnimated:NO completion:NULL];
                     }];
}

好的,我想我明白了,我所做的是将 整个导航控制器视图 插入源视图的父视图并删除代码以 从superview 并将 dismissViewControllerAnimated 的选项设置为 YES,如下所示:

- (void) perform {
    UIViewController *origenViewcontroller  = self.sourceViewController;
    UIViewController *destinoViewcontroller = self.destinationViewController;

    [origenViewcontroller.view.superview insertSubview:destinoViewcontroller.navigationController.view atIndex:0];

    [UIView animateWithDuration:0.4
                          delay:0.0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         origenViewcontroller.view.transform = CGAffineTransformMakeScale(2.0, 2.0);
                         origenViewcontroller.view.alpha = 0.0;
                     }
                     completion:^(BOOL finished){
                         [origenViewcontroller dismissViewControllerAnimated:YES completion:NULL];
                     }];
}

我仍然不确定这是否是正确的做法。

【问题讨论】:

  • 欢迎来到 SO!如果您尝试发布您正在使用的代码示例,这通常很有用,以便人们可以查看它以尝试帮助您。

标签: ios objective-c animation segue uistoryboardsegue


【解决方案1】:

您也可以将destinationViewController 嵌入到UINavigationController 中,并将您的segue 从sourceViewController 设置为Navigation Controller

【讨论】:

  • fabf98dev 是正确的,如果您为要展开的UIViewController 创建自定义导航控制器,并将展开调用放在那里,那么导航栏将在展开转场期间保持不变。
猜你喜欢
  • 2017-02-15
  • 1970-01-01
  • 1970-01-01
  • 2012-06-02
  • 2013-10-15
  • 1970-01-01
  • 2019-12-29
  • 1970-01-01
相关资源
最近更新 更多