【问题标题】:Using a custom transition layout when doing layout-to-layout navigation transitions在进行布局到布局导航转换时使用自定义转换布局
【发布时间】:2013-11-10 15:57:09
【问题描述】:

我将UICollectionViewControlleruseLayoutToLayoutNavigationTransitions 属性设置为“YES”,以便为-[UINavigationController pushViewController:animated:]popViewControllerAnimated: 执行布局到布局转换。此外,我还实现了基于捏合手势的交互式过渡。

另外,我定义了一个自定义的UICollectionViewTransitionLayout,它的行为与UICollectionViewTransitionLayout 的原始行为不同。我创建了我的“CustomLayoutTransition”对象的一个​​实例并从-[UICollectionViewDelegate collectionView:transitionLayoutForOldLayout:newLayout:] 返回它。

当我这样做时,我期待两种行为

CustomLayoutTransition 用于执行自定义布局到布局的转换
1) 当捏合手势触发交互过渡时,或
2) 当我推送/弹出UICollectionViewController 的实例时,例如,通过调用[UINavigationController pushViewController:animated:]

我的期望#1 似乎是正确的,但#2 不是;似乎当我以编程方式推送/弹出时,使用 Apple 提供的原始 UICollectionViewTransitionLayout 而不是我的自定义过渡布局。

在这种情况下使用UICollectionViewTransitionLayout而不是我的自定义过渡布局是否正常?

如果这是正常行为,是否有办法在以编程方式推送/弹出UICollectionViewController 时使用自定义转换来执行布局到布局转换?

【问题讨论】:

  • 我刚刚遇到了这种行为,很想看到答案。我希望在这两种情况下都使用我的自定义转换布局,但我也很困惑如果用户没有交互,transitionProgress 将如何更新。
  • 有什么更新吗?
  • 也对这个问题感兴趣。只是想补充一点,我还测试了一个 UIViewController 和一个 UICollectionView,调用 [self.collectionView setCollectionViewLayout:newLayout animated:YES] 并且提到的委托方法 ([UICollectionViewDelegate collectionView:transitionLayoutForOldLayout:newLayout:]) 也没有被调用.
  • 这里有你的答案。链接到 -> stackoverflow.com/questions/22479844/…

标签: ios cocoa-touch uicollectionview transition uicollectionviewlayout


【解决方案1】:

这更像是一种变通方法,而不是正确的解决方案,但假设您想通过以下方式更改布局:

[self.collectionView setCollectionViewLayout:self.finalLayout animated:YES];

但您想提供自己的 UICollectionViewTransitionLayout,您可以将上面的行替换为:

[self.collectionView startInteractiveTransitionToCollectionViewLayout:self.finalLayout completion:nil];
[self.collectionView finishInteractiveTransition];

和委托方法

- (UICollectionViewTransitionLayout*)collectionView:(UICollectionView *)collectionView transitionLayoutForOldLayout:(UICollectionViewLayout *)fromLayout newLayout:(UICollectionViewLayout *)toLayout

按预期调用。

再次,我希望调用委托方法而无需以这种奇怪的方式触发转换,但事实并非如此。

【讨论】:

    猜你喜欢
    • 2013-11-19
    • 2019-12-12
    • 2017-10-01
    • 1970-01-01
    • 2019-06-02
    • 1970-01-01
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    相关资源
    最近更新 更多