UILabel 및 UIImageView가 포함 된 사용자 정의 셀이 있습니다. JSON을 사용하여 데이터 검색. 텍스트를 검색 할 때 내 UISearchBar가 완벽하게 작동하지만 UIImageView의 인덱스가 변경되지 않습니다.UIImageView 및 UILabel이 포함 된 사용자 정의 셀에서 UISearchBar 검색
-(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];
}
제게 조언을주십시오. 이 문서가 문제를 해결하는 것입니다
-(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(int i = 0; i < [userNames count]; i++) {
NSString *string = [userNames objectAtIndex:i];
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.
[displayPictures addObject:[profilePictures objectAtIndex:i]];
}
}
}
[tableView reloadData];
}
나는 당신의 요구 사항에 따라 코드를 수정했다
아니 좋은 방법 애플을 참조 //developer.apple.com/library/ios/#samplecode/TableSearch/Introduction/Intro.html –