Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. -(BOOL)searchDisplayController:(UISearchDisplayController *)controller
  2. shouldReloadTableForSearchString:(NSString *)searchString
  3. {
  4. [self filterContentForSearchText:searchString
  5. scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
  6. objectAtIndex:[self.searchDisplayController.searchBar
  7. selectedScopeButtonIndex]]];
  8.  
  9. return YES;
  10. }
  11.  
  12.  
  13. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  14. {
  15. if (tableView == self.searchDisplayController.searchResultsTableView) {
  16. return [searchResults count];
  17.  
  18. } else {
  19. return [categories count];
  20. }
  21. }
  22.  
  23.  
  24. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  25. {
  26. static NSString *simpleTableIdentifier = @"FirstTableCell";
  27.  
  28. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
  29.  
  30. if (cell == nil) {
  31. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
  32. }
  33. if (tableView == self.searchDisplayController.searchResultsTableView) {
  34. cell.textLabel.text = [searchResults objectAtIndex:indexPath.row];
  35. } else {
  36. cell.textLabel.text = [categories objectAtIndex:indexPath.row];
  37.  
  38. }
  39.  
  40. cell.imageView.image = [UIImage imageNamed:[thumbnails objectAtIndex:indexPath.row]];
  41.  
  42.  
  43. return cell;
  44. }
  45.  
  46.  
  47.  
  48. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  49. {
  50. if (tableView == self.searchDisplayController.searchResultsTableView) {
  51. [self performSegueWithIdentifier: @"showArrayDetail" sender: self];
  52. }
  53. }
  54.  
  55.  
  56. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  57. if ([segue.identifier isEqualToString:@"showArrayDetail"]) {
  58. SecondViewController *destViewController = segue.destinationViewController;
  59.  
  60. NSIndexPath *indexPath = nil;
  61.  
  62. if ([self.searchDisplayController isActive]) {
  63. indexPath = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
  64. destViewController.categoryName = [searchResults objectAtIndex:indexPath.row];
  65.  
  66. } else {
  67. indexPath = [self.tableView1 indexPathForSelectedRow];
  68. destViewController.categoryName = [categories objectAtIndex:indexPath.row];
  69.  
  70. }
  71. }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement