ShannonChenCHN/YHListKit

关于collectionView的header触摸事件,有办法通过adapter的delegate取到吗,如果不行就只能写在view里面了

Closed this issue · 1 comments

关于collectionView的header触摸事件,有办法通过adapter的delegate取到吗,如果不行就只能写在view里面了

@Girlsmile
你可以通过通过实现 YHCollectionViewAdapterDelegate 代理方法 -collectionViewAdapter:didDequeueSupplementaryView:ofKind:atIndexPath: 来给你的 header 设置 delegate 或者 block。比如:

- (void)collectionViewAdapter:(YHCollectionViewAdapter *)adapter didDequeueSupplementaryView:(UICollectionReusableView *)view ofKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
     Header *header = (Header *)view;
     header.block = ^{
           // 在这里处理 header 的点击事件回调
     };
}