ios - UITabBarController 动画的转换委托(delegate)

标签 ios swift transitions xcode6 uiviewanimationtransition

我已经创建了一个自定义的 UIViewControllerAnimationTransition 类,并且需要在它切换选项卡时使它成为 UITabBarController 的动画。

不过,tabBarController 不使用常规标签栏。我有一个类似它的自定义实现,当按下按钮时,它会调用此代码:

tabBarController.selectedIndex = index

目前我有 tabBarController(子类)作为它自己的 transitionDelegate 的委托(delegate)。不过,委托(delegate)方法 animationControllerForPresentedController 从未真正被调用过。

标签栏 Controller 可以作为自己的委托(delegate)吗?如果是这样,为什么从未实际调用转换代码?

最佳答案

animationControllerForPresentedController 是标签栏 Controller 的错误方法。

在UITabBarController子类中,采用UITabBarControllerDelegate协议(protocol),并将其设置为自己的delegate。然后,使用 tabBarController: animationControllerForTransitionFromViewController: toViewController: 返回自定义的 UIViewControllerAnimatedTransitioning 对象。

要获得更好的可视化效果,请查看 VCTransitionsLibrary在 TabBarDemo 文件夹中。

关于ios - UITabBarController 动画的转换委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24923625/

相关文章:

ios - 解析中的投票实现

ios - 在 layoutSubviews 绘制圆角,但不适用于所有屏幕尺寸

iphone - iOS : UIScrollView and OpenGL

ios - NSUserDefaults 和我自己的链表实现

json - 在 Swift 中解析巨大的 json 数组

ios - 选择单元格时如何自动滚动collectionviewcell到最近的单元格(上一个或下一个)

ios - 看不到标签栏图像

ios - 在自定义动画过渡期间淡入背景 View

ios - 在导航 Controller 上推送时 View 变暗

ios - 交互式过渡,如谷歌地图 (iOS)