【发布时间】:2013-07-03 16:08:34
【问题描述】:
我在我的应用程序中使用 UISearchBar。
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
[self.filtered removeAllObjects];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.companyName contains[cd] %@",searchText];
NSArray *tempArray = [ee filteredArrayUsingPredicate:predicate];
filtered = [NSMutableArray arrayWithArray:tempArray];
}
我在上面的“过滤”数组上做了NSLog,它得到了正确的搜索结果。
我没有在表格视图中看到过滤后的值。如果我输入错误的搜索文本,我会看到“无结果”。但是对于正确的搜索文本,表格视图是空的。
谁能帮我做什么?
提前致谢!!
【问题讨论】:
-
检查你的数组是否为空
-
你是否重新加载了tableview。过滤后的数组是tableview的数据源吗?
-
我的过滤数组不为空,我做了 NSLog 来查看过滤后的值。我在 cellForRowAtIndexPath 方法和 numberOfRowsInSection 中也看到了过滤后的数组值。
-
我在 viewDidLoad 中只有一个重新加载调用。我不确定您所说的过滤数组是数据源是什么意思?我没有明确说它是数据源。如果我错过了,请告诉我该怎么做。谢谢。
-
你能贴出
cellForRowAtIndexPath代码吗?
标签: ios uisearchbar uisearchbardelegate