2016-12-07 16 views
0

UIViewサブクラスをコレクションビューフッター(UICollectionReusableView)として使用したいと考えています。クラスがすでにUIViewのUIViewサブクラスをUICollectionViewフッターとして使用する方法

func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView { 
    guard let footerView = self.collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionFooter, withReuseIdentifier:"CustomUIView", forIndexPath: indexPath) as? UICollectionReusableView else { break } 
    return footerView 
} 

答えて

1

として書かれているので、それはUICollectionReusableViewからサブクラス化しない場合は、UICollectionReusableViewとしてあなたCustomUIViewをキャストすることはできません。それはあなたのニーズのために働く場合は、あなたではなくUIViewからUICollectionReusableView継承しているのでUIView

  • をサブクラス化するよりも、あなたのCustomUIViewクラスのUICollectionReusableViewをサブクラス化することができ、

    • あなたはオプションのカップルを持っていますCustomUIViewを作成して新しいUICollectionReusableViewを作成し、作成したCustomUIViewをサブビューとして追加します

  • 関連する問題