【问题标题】:iOS7 Implement UIViewControllerTransitioningDelegate with StoryboardiOS7 用 Storyboard 实现 UIViewControllerTransitioningDelegate
【发布时间】:2014-01-14 10:42:00
【问题描述】:

从 iOS7 开始,我们可以使用 UIViewControllerTransitioningDelegate 创建从视图控制器到视图控制器的自定义过渡,它允许细粒度的过渡。

viewController.transitioningDelegate  = transitioningDelegate;

我发现在使用情节提要时,我们已经有机会使用自定义UIStoryboardSegue 创建自定义转场,但这似乎是使用情节提要实现自定义转场的唯一方法。

如何在使用情节提要时实现转换委托?

【问题讨论】:

    标签: iphone ios objective-c uikit


    【解决方案1】:

    检查http://www.teehanlax.com/blog/custom-uiviewcontroller-transitions/

    想法是使用- prepareForSegue:transitioningDelegatemodalPresentationStyle 设置为UIModalPresentationCustom。然后,您的过渡代表将不得不处理过渡。

    【讨论】:

    • 你好,我有一个问题:我没有在prepareForSegue 中设置modalPresentationStyle,并且我在animationControllerForPresentedControlleranimateTransition 方法之间有一个时间间隔(大约0.4 秒非常了不起)有时甚至是 0.7;我的过渡动画是 1 秒长加上这个间隙。几乎是两倍的时间。)。我试图找出这段时间间隔内发生了什么,但这不是错(我认为),因为我没有可能造成这种延迟的流程。当我添加 modalPresentationStyle = UIModalPresentationCustom 时,这个差距就消失了。为什么会这样?谢谢。
    • 只是猜测:如果您简化设置,您可能会发现正在播放动画。可能是您设置视图层次结构的方式不允许您看到此动画。
    【解决方案2】:

    查看以下示例: https://github.com/soleares/SOLPresentingFun

    它是 WWDC Session 218: Custom Transitions Using View Controllers 示例代码的实现。它使用故事板。

    【讨论】:

      猜你喜欢
      • 2016-12-02
      • 2013-11-17
      • 2012-04-02
      • 2012-04-11
      • 2017-12-08
      • 1970-01-01
      • 2015-11-28
      • 2014-02-13
      • 1970-01-01
      相关资源
      最近更新 更多