具有不同数据源的UICollectionView UseLayoutToLayoutNavigationTransitions [英] UICollectionView UseLayoutToLayoutNavigationTransitions with different datasources

查看:198
本文介绍了具有不同数据源的UICollectionView UseLayoutToLayoutNavigationTransitions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 UICollectionView 对象,它们都有不同的源和委托。我想使用UseLayoutToLayoutNavigationTransitions来实现照片app'esque外观转换。

I have two UICollectionView objects, that both have different source and delegate. I would like to achieve a "Photos app'esque" look with the transition, using UseLayoutToLayoutNavigationTransitions.

虽然它不起作用。当我调用 UseLayoutToLayoutNavigationTransitions 时,它会更改布局,但不会更改内容。

It doesn't work though. When I call the UseLayoutToLayoutNavigationTransitions it changes the layout, but not the content.

第一张图片是第一个集合视图。一系列类别和包含在其中的人物。

First picture is first collection view. A series of categories and the people contained in them.

第二张图片是我想要动画结束的内容。特定类别中的一系列人物。

Second picture is what I'd like the animation to end up in. A series of people within a certain category.

最后的图片就是现在发生的事情。类别只是重新排列。

Last picture is what happens right now. Categories just get rearranged.

推荐答案

看看 http://www.objc.io/issue-12/collectionview-animations.html


UICollectionViewController实例之间的转换

Transitions Between UICollectionViewController Instances

section。

它基本上表明你必须通过实现导航控制器委托方法手动更改数据源和委托:

it basically shows you that you'll have to change the datasource and delegate manually by implementation of the navigation controller delegate methods:

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if ([viewController isKindOfClass:[FJDetailViewController class]]) {
        FJDetailViewController *dvc = (FJDetailViewController*)viewController;
        dvc.collectionView.dataSource = dvc;
        dvc.collectionView.delegate = dvc;
        [dvc.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:_selectedItem inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:NO];
    }
    else if (viewController == self){
        self.collectionView.dataSource = self;
        self.collectionView.delegate = self;
    }
}

这篇关于具有不同数据源的UICollectionView UseLayoutToLayoutNavigationTransitions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆