我有一个包含 UILabel 和 UIImageView 的自定义单元格。使用 JSON 检索数据。我的 UISearchBar 在搜索文本时工作正常,但我的 UIImageView 的索引没有改变。
-(void) searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
if (searchText.length == 0) {
isSearchBarClicked = FALSE;
[displayItems removeAllObjects];
[displayItems addObjectsFromArray:userNames];
[displayPictures removeAllObjects];
[displayPictures addObjectsFromArray:profilePictures];
} else {
isSearchBarClicked = true;
[displayItems removeAllObjects];
[displayPictures removeAllObjects];
for (NSString * string in userNames) {
NSRange r = [string rangeOfString:searchText options:NSCaseInsensitiveSearch];
if (r.location != NSNotFound) {
[displayItems addObject:string];
//I HAVE TO ADD OBJECT TO displayPictures FROM profilePictures IN HERE.
}
}
}
[tableView reloadData];
}
请给我一个建议。