0

我目前正在使用提供的 API 来定义自定义控制器转换。我阅读了 Apple 提供的文档,查看了 WWDC 上的视频,发现很多博客都在谈论它。我对如何使用这些 API 有一些疑问:

  1. 容器视图animateTransition::在我找到的大多数示例代码和名为“使用视图控制器的自定义转换”的 WWDC 218 中,只有“toViewController”的视图被添加到containerView. 但在其他一些示例和视频“Architecting Modern iOS Apps”中,显示的代码将“toViewController”和“fromViewController”都添加到containerView. 我们什么时候应该同时处理两者,什么时候只处理一个?解雇和呈现是否相同?
  2. initialFrameForViewController:上下文:WWDC 218 视频告诉我们,finalFrameForViewController:依靠这些UIViewControllerContextTransitioning方法来检索控制器视图的帧非常重要。但是在很多例子中,根本没有使用。我尝试在自定义动画中使用 then,但提供的框架可能位于屏幕之外。这些方法如何确定帧?什么时候应该使用这些方法?它是否在文档中指定?
  3. viewForKey:在 iOS8 中:我们应该使用这种方法而不是viewControllerForKey:自 iOS 8 开始吗?
  4. 在自定义动画转换期间视图层次结构中是否有modalPresentationStyle事件?在此处提供的幻灯片上:http: //es.slideshare.net/Split82/custom-uiviewcontroller-transitions,这似乎与初始帧和最终帧有关。它记录在某处吗?
4

1 回答 1

0
  1. Regarding what view controllers you need to add, you only have to add the "to" view. The "from" view is already there.

  2. Regarding your finalFrameForViewController, it's probably dictated by things like UIModalPresentationFullscreen vs UIModalPresentationPopover and preferredContentSize.

  3. Regarding viewForKey, this is useful in those cases where the presented view is not the same as the presenting view controller's view (e.g. the custom transition is presenting a popup that also blurs the "from" view, which is full screen, even though the presented view is a small pop-up). In many cases, you don't need viewForKey. It just depends upon what you're doing.

  4. Yes, the modalPresentationStyle affects the frame sizes (e.g. popover vs full screen vs UIModalPresentationNone). The WWDC 2014 video #214 View Controller Advancements in iOS 8 demonstrates this in practice.

于 2015-03-11T14:15:20.880 回答