简体   繁体   中英

How can I receive results from TableViewController?

I have TableViewController with titles and TableViewController with images. I create seachBar in TableViewController with titles and when I searching in TableViewController with titles I want to receive results from TableViewController with images. How can I do this?

Added the search. But it works only with arrays in this controller. How do I make filters for arrays to another controller?

 NSPredicate *resultPredicate = [NSPredicate
                                predicateWithFormat:@"SELF contains[cd] %@",
                                searchText];
if (_animalInt == 0){
_searchResults = [_Arra filteredArrayUsingPredicate:resultPredicate];
}
else if (_animalInt == 1){
    _searchResults = [_Arra1 filteredArrayUsingPredicate:resultPredicate];
 }
 else if (_animalInt == 2){
    _searchResults = [_Arra2 filteredArrayUsingPredicate:resultPredicate];
}

Doesn't work

TableViewController *detailViewController;

NSPredicate *resultPredicate = [NSPredicate
                                predicateWithFormat:@"SELF contains[cd] %@",
                                searchText];
if (_animalInt == 0){
_searchResults = [detailViewController.arra7 filteredArrayUsingPredicate:resultPredicate];
}
else if (_animalInt == 1){
    _searchResults = [detailViewController.arra18 filteredArrayUsingPredicate:resultPredicate];
}
else if (_animalInt == 2){
    _searchResults = [detailViewController.arra20 filteredArrayUsingPredicate:resultPredicate];
}

I recommend you use UISearchDisplayController with UISearchBar.

It's recommended by Apple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM