Pregunta

En mi aplicación, cuando no estoy filtrando mi mesa, cuando toco en una célula, su altura de bastidor se incrementa con el fin de mostrar una UIProgressView que muestra el progreso de descarga.

Sin embargo, cuando filtrar los datos resultados de controlador exageradas con un UISearchDisplayController, las células en este punto de vista tabla filtrada no se comportan de la misma manera.

En lugar de ello, la célula no cambia el tamaño, no muestra la vista de los progresos, no desencadena una descarga, y la aplicación se bloquea posteriormente.

¿Cómo puedo obtener el control de la vista de tabla que se presenta a la hora de filtrar los resultados con UISearchDisplayController?

Editar

Este es mi método -tableView:didSelectRowAtIndexPath:. Es un poco largo, pero lo esencial es que funciona muy bien cuando no estoy buscando.

Creo que necesito para adaptar esto de alguna manera, de modo que pueda trabajar con cualquier tabla Ver los resultados inverosímiles / controlador que el controlador resultados de búsqueda está lanzando en este.

- (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...
                        }
                    }
                }
            }
        }
    }
}
¿Fue útil?

Solución

En cualquiera de los métodos vista de tabla de delegado, puede detectar si se está trabajando con la vista de la tabla de la UISearchDisplayController utilizando la siguiente comprobación:

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

Otros consejos

Normalmente, se compruebe si la vista de tabla que se pasa a tableView:didSelectRowAtIndexPath: es igual a un comportamiento alternativo "searchResultsTableView" y el programa de su controlador de pantalla de búsqueda para ese caso.

Parece que su problema puede ser más complicado. Se puede publicar el código para tableView:didSelectRowAtIndexPath:?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top