How to filter UICollectionView and keep keyboard up?

前端 未结 11 1590
旧时难觅i
旧时难觅i 2020-12-30 23:47

I\'ve added a UISearchBar to a UICollectionView and in the delegate searchBar:textDidChange: filter my model and call [collectio

11条回答
  •  醉话见心
    2020-12-31 00:39

    In searchBar delegate function , I use performBatchUpdates, first,reload collectionView then call [self.searchBar becomeFirstResponder] to display keyboard

    - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar{
        [self setEditing:NO animated:YES];
        [searchBar setShowsCancelButton:YES animated:YES];
    
            [self.collectionView performBatchUpdates:^{
                [self.collectionView reloadData];
            } completion:^(BOOL finished) {
                [self.searchBar becomeFirstResponder];
            }];
    }
    

提交回复
热议问题