How to reload only data section of UICollectionView?

烈酒焚心 提交于 2019-12-03 08:35:15
glast

I think the error only occurs when the search bar is a collection view's subview, and trying to call reloadSections: when the keyboard input is up.

This article gives an answer to a similar problem, but that didn't work for me.

So I used an alternative way with which I can invoke almost the same feature.

Instead of adding the header as a supplementary view, I made the header a subview of 'view'. (not collectionView)

And added some scroll delegate to mimic the table view's header.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat y = scrollView.contentOffset.y;
    if (y < 44) {
        [self.searchBar setFrame:CGRectMake(0, -y, 320, 44)];
        [self.searchBar setHidden:NO];
    } else if (y >= 44) {
        [self.searchBar setHidden:YES];
    }  
} 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!