Rubymotion:向UICollectionView添加页脚

时间:2015-09-08 02:39:58

标签: ios rubymotion

使用Rubymotion和RMQ向UICollectionView添加页脚时遇到了麻烦。

只添加一个标题可以正常工作,但只需一个页脚或页眉和页脚都不起作用。

我用这个

COLLECTION_HEADER_ID = "SectionHeader"
...
cv.registerClass(SectionHeader, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: COLLECTION_HEADER_ID)
...
def collectionView(view, viewForSupplementaryElementOfKind:kind, atIndexPath:path)
      view.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier:COLLECTION_HEADER_ID, forIndexPath:path)

在这种情况下,打印标题。 然后我添加

COLLECTION_FOOTER_ID = "SectionFooter"
...
cv.registerClass(SectionFooter, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: COLLECTION_FOOTER_ID)

并更改我的viewForSupplementaryElementOfKind函数:

def collectionView(view, viewForSupplementaryElementOfKind:kind, atIndexPath:path)
  if kind == UICollectionElementKindSectionFooter
    return
    view.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier:COLLECTION_HEADER_ID, forIndexPath:path)
  end
    return view.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier:COLLECTION_HEADER_ID, forIndexPath:path)
end

跑耙,我没有错,但我也没有页脚......  在viewForSupplementaryElementOfKind函数中," kind"总是UICollectionElementKindSectionHeader,我不明白为什么......

如果我尝试只显示页脚,我会

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the view returned from -collectionView:viewForSupplementaryElementOfKind:atIndexPath (UICollectionElementKindSectionHeader,<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}) was not retrieved by calling -dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath: or is nil ((null))'

&#34;种类&#34;再次UICollectionElementKindSectionHeader

UICollectionElementKindSectionHeader?您是否被迫使用标题来使用页脚?

对此有任何提示吗?

0 个答案:

没有答案