// The method to change the predicate of the FRC- (voID)filterContentForSearchText:(Nsstring*)searchText{ Nsstring *query = searchText; if (query && query.length) { nspredicate *predicate = [nspredicate predicateWithFormat:@"name contains[cd] %@ or createdAt contains[cd] %@ or noteText contains[cd] %@ or keywords contains[cd] %@",query,query]; [self.fetchedResultsController.fetchRequest setPredicate:predicate]; } else { [self.fetchedResultsController.fetchRequest setPredicate:nil]; } NSError *error = nil; if (![[self fetchedResultsController] performFetch:&error]) { // Handle error NSLog(@"Error"); } [self.collectionVIEw reloadData];}
每次搜索栏文本更改时都会调用此方法. [self.collectionVIEw reloadData]行为每个字符隐藏键盘.是否可以仅重新加载UICollection视图中的数据,而不是重新加载补充视图,如段标题头?
我的collectionVIEw中的数据来自一个NSFetchResultController.
我很高兴我的用户界面如何工作,所以如果有一个简单的方法来不重新加载部分标题,那将是非常好的!
解决方法 尝试了许多不同的选择后,我终于明白了这一点.解决方案是使您自己的部分的标题,以便您可以独立重新加载其他部分,而无需重新加载头部附加到的部分.所以:
>第0节
>标题
>搜索栏(或其他文本字段)
>行
>(无)
>第1节
>标题
>创建一个空的UICollectionReusableVIEw并覆盖… sizeforItemAtIndexPath:(NSIndexPath *)indexPath返回CGSizeZero
>行
>您的实际行,最初将与第0节
然后,我们需要重新加载数据:
[collectionVIEw reloadSections:[NSIndexSet indexSetWithIndex:1]];
您的搜索栏或文本字段应该在用户打字时保留焦点,并且可以在后台更新结果.
总结以上是内存溢出为你收集整理的ios – UICollectionView reloadData在section header中重新指定第一个响应者全部内容,希望文章能够帮你解决ios – UICollectionView reloadData在section header中重新指定第一个响应者所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)