IOS CollectionView“一个工作示例”

时间:2013-12-18 01:17:02

标签: ios uicollectionview uicollectionviewlayout

我正在尝试让代码工作来创建一个collectionView来创建我的核心数据的Hierarchical视图,就像Apple的例子一样,但我不明白他们是如何解释如何使用补充视图来表示连接单元格的线

例如,我是否创建了1个补充视图并使用子视图来创建位于数据对象之间的连接线或...

我是否创建了许多补充视图,每个视图都包含连接线图形并将它们放在数据对象之间?

非常感谢

Apple的文档见链接..

https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/AWorkedExample/AWorkedExample.html#//apple_ref/doc/uid/TP40012334-CH8-SW6

清单6-9创建补充视图的属性对象

// create another dictionary to specifically house the attributes for the supplementary view
NSMutableDictionary *supplementaryInfo = [NSMutableDictionary dictionary];
//…
// within the initial pass over the data, create a set of attributes for the supplementary views as well
UICollectionViewLayoutAttributes *supplementaryAttributes = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:@"ConnectionViewKind" withIndexPath:indexPath];
[supplementaryInfo setObject: supplementaryAttributes forKey:indexPath];
//…
// in the second pass over the data, set the frame for the supplementary views just as you did for the cells
UICollectionViewLayoutAttributes *supplementaryAttributes = [supplementaryInfo objectForKey:indexPath];
supplementaryAttributes.frame = [self frameForSupplementaryViewOfKind:@"ConnectionViewKind" AtIndexPath:indexPath];
[supplementaryInfo setObject:supplementaryAttributes ForKey:indexPath];
//...
// before setting the instance version of _layoutInformation, insert the local supplementaryInfo dictionary into the local layoutInformation dictionary
[layoutInformation setObject:supplementaryInfo forKey:@"ConnectionViewKind"];

0 个答案:

没有答案