6

Dans mon application, lorsque je ne filtre pas ma table, lorsque j'appuie sur une cellule, sa hauteur d'image est augmentée afin d'afficher un UIProgressView qui indique la progression du téléchargement.Comment contrôler la propre vue de la table de UISearchDisplayController?

Toutefois, lorsque je filtre les données de contrôleur de résultats récupérées avec UISearchDisplayController, les cellules de cette vue de tableau filtrée ne se comportent pas de la même manière. Au lieu de cela, la cellule ne redimensionne pas, n'affiche pas la vue de progression, ne déclenche pas de téléchargement et l'application se bloque par la suite.

Comment prendre le contrôle de la vue de table présentée lors du filtrage des résultats avec UISearchDisplayController?

EDIT

Voici ma méthode -tableView:didSelectRowAtIndexPath:. C'est un peu long, mais l'essentiel est que ça marche bien quand je ne cherche pas.

Je pense que j'ai besoin de l'adapter d'une manière ou d'une autre, de sorte qu'il puisse fonctionner avec n'importe quel contrôleur de vue de table/résultats récupérés par le contrôleur de résultats de recherche.

- (void) tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    [tv deselectRowAtIndexPath:indexPath animated:YES]; 

    if ([self.searchBar isFirstResponder]) 
     [self.searchBar resignFirstResponder]; 

    MyObject *_myObject = (MyObject *)[self.fetchedResultsController objectAtIndexPath:indexPath]; 

    if (self.isSimulatingFileHierarchy) 
    { 
     if ([_myObject isFolder]) 
     { 
      ObjectsViewController *_objectsViewController = [[ObjectsViewController alloc] initWithNibName:@"ObjectsViewController" bundle:nil]; 
      _objectsViewController.managedObjectContext = self.managedObjectContext; 
      _objectsViewController.nodeID = self.nodeID; 
      _objectsViewController.nodeName = self.nodeName; 
      _objectsViewController.parentObjectKey = [_myObject cleanedKey]; 

      if (self.parentObjectKey) 
       _objectsViewController.title = [[_myObject cleanedKey] stringByTrimmingPrefix:[self.parentObjectKey stringByAppendingString:@"/"]]; 
      else 
       _objectsViewController.title = [_myObject cleanedKey]; 

      [self.navigationController pushViewController:_objectsViewController animated:YES]; 
      UIBarButtonItem *_backButton = [[UIBarButtonItem alloc] initWithTitle:self.title style:UIBarButtonItemStyleDone target:nil action:nil]; 
      self.navigationItem.backBarButtonItem = _backButton; 
      [_backButton release]; 
      [_objectsViewController release]; 
     } 
     else { 
      // 
      // If we don't have data cached for this object, we add a request for the object's bytes to the objectRequestQueue 
      // 
      // 1. We add a progress indicator to the object's cell (we have an indexPath) 
      // 2. We store the data to the Documents folder 
      // 
      // Once we have the data, we push a ViewerViewController subclass that is specific to the object content type 
      // 

      if ((!_myObject.isDownloading) && ([_myObject.localPath length] == 0)) 
      { 
       if ([AwsObject objectContentSupportedForType:[_myObject.contentType intValue]]) 
       { 
        // 
        // Start request and redraw row with UIProgressView 
        // 
        [self triggerObjectRequestAdditionForObject:_myObject atIndexPath:indexPath]; 
       } 
       else { 
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"ObjectsViewObjectRequestUnsupportedTypeAlertViewTitle", @"") message:NSLocalizedString(@"ObjectsViewObjectRequestUnsupportedTypeAlertViewMessage", @"") delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"ObjectsViewObjectRequestUnsupportedTypeAlertViewContinue", @""), nil]; 
        [alert show]; 
        [alert release]; 
       } 
      } 
      else if ((_myObject.isDownloading) && ([_myObject.localPath length] == 0)) 
      { 
       // 
       // Cancel request and redraw row without progress view 
       // 
       [self triggerObjectRequestRemovalForObject:_myObject atIndexPath:indexPath]; 
      } 
      else if ((!_myObject.isDownloading) && ([_myObject.localPath length] != 0)) 
      { 
       // 
       // Launch viewer for supported MIME type 
       // 
       switch ([_myObject.contentType intValue]) { 
        case kObjectContentTypeApplicationMsword: { 
         [self pushWebViewerViewController:_myObject withTextEncoding:@"UTF-8"]; 
         break; 
        } 
        // handle other MIME types here... 
       } 
      } 
      else { 
       if ([_myObject isFolder]) { } 
       else { 
        if ((!_myObject.isDownloading) && ([_myObject.localPath length] == 0)) 
         [self triggerObjectRequestAdditionForObject:_myObject atIndexPath:indexPath]; 
        else if ((_myObject.isDownloading) && ([_myObject.localPath length] == 0)) 
         [self triggerObjectRequestRemovalForObject:_myObject atIndexPath:indexPath]; 
        else if ((!_myObject.isDownloading) && ([_myObject.localPath length] != 0)) { 
         switch ([_myObject.contentType intValue]) { 
          case kObjectContentTypeApplicationMsword: { 
           [self pushWebViewerViewController:_myObject withTextEncoding:@"UTF-8"]; 
           break; 
          } 
          // handle other MIME types here... 
         } 
        } 
       } 
      } 
     } 
    } 
} 

Répondre

12

En tout état de la vue de la table des méthodes de délégué, vous pouvez détecter si vous travaillez avec vue sur la table du UISearchDisplayController en utilisant le contrôle suivant:

if (tableView == self.searchDisplayController.searchResultsTableView) { 
    // behavior specific to search display controller table view 
} 
else { 
    // behavior specific to the original, unfiltered table view 
} 
0

En règle générale, vous vérifier si la vue de la table étant passée à tableView:didSelectRowAtIndexPath: est égal à votre « searchResultsTableView » de contrôleur d'affichage de recherche et programme comportement alternatif pour ce cas.

Il semble que votre problème soit plus compliqué. Pouvez-vous poster le code pour tableView:didSelectRowAtIndexPath:?