我们可以将UISearchBar添加到UICollectionView标头

时间:2014-02-12 11:57:57

标签: uicollectionview uisearchbar

我正在使用UICollectionView,我想在其中添加UISearchBarUISearchDisplayController。 我能做到吗我想要一些例子。

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    UICollectionReusableView *reusableview = nil;

    if (kind == UICollectionElementKindSectionHeader) {

        CollectionReusable *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeadCell" forIndexPath:indexPath];

        reusableview = headerView;
    }

    if (kind == UICollectionElementKindSectionFooter) {

        CollectionReusable *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FootCell" forIndexPath:indexPath];

        reusableview = footerView;
    }

    return reusableview;
}

1 个答案:

答案 0 :(得分:-1)

有点晚了但是this repository包含了处理这个问题的很多代码。

相关问题