9

Quiero construir una aplicación para reproducir archivos de audio locales en el iPhone, pero estoy atascado con algunos de mis códigos. Me pregunto cómo se puede presionar una vista, volver al controlador de uitableview y usar un botón (como el botón "AHORA REPRODUCIENDO" en el reproductor multimedia) para volver a la vista sin introducir ningún hilo nuevo en ella ...¿Cómo presionar una vista, regresar y volver a la vista?

GRACIAS

¿Qué debería cambiar de mis códigos?

en el UITableViewController ..

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath 
    *)indexPath { 
selectedSong = [directoryContent objectAtIndex:indexPath.row]; 
NSString *storyLin = [[directoryContent objectAtIndex:[indexPath row]] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 
patch = [NSString stringWithFormat:@"/%@", storyLin]; 


     myDetViewCont = [[mPlayerViewController alloc] initWithNibName:@"mPlayerViewController" bundle:nil];  
myDetViewCont.myProgLang = selectedSong; // assigning the correct value to the variable inside DetailViewController 
     [self.navigationController pushViewController:myDetViewCont animated:YES]; 
     [myDetViewCont release]; // releasing controller from the memory 

    } 

en mPlayerViewController.m

-(IBAction) backtoplayer{ 
    myDetViewCont = [[mPlayerViewController alloc] initWithNibName:@"mPlayerViewController" bundle:nil]; 
} 

Respuesta

11

Si ha empujado a una vista sobre el control de navegación, póngalo para revisar la vista desde abajo.

Es decir, la vista que presione myDetViewCont debería aparecer en la llamada backtoplayer.

- (IBAction)backToPlayer:(id)sender { 
    [self.navigationController popViewControllerAnimated:YES]; 
} 
4

que añadir a lo que dijo Mark.

Una vez que haya popViewControllerAnimado y el usuario desea volver a presionar el mismo controlador, solo necesita mantener el mPlayerViewController en lugar de liberarlo.

Tales como:

if (!myDetViewCont) 
    { // We only need to create it once. 
      myDetViewCont = [[mPlayerViewController alloc] initWithNibName:@"mPlayerViewController" bundle:nil];  
    } 
    myDetViewCont.myProgLang = selectedSong; 
    [self.navigationController pushViewController:myDetViewCont animated:YES]; 
    // no longer release here, move the release call to the dealloc 
+0

Amazing !!!! ¡GRACIAS a los dos! Pero, ¿cómo puedo evitar que se cree un nuevo mPlayerViewController cada vez que alguien hace clic en una fila (canción) en el controlador uitableviewController? '(void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { myDetViewCont = [[mPlayerViewController alloc] initWithNibName: @" mPlayerViewController "paquete: nil]; ' – Alby

Cuestiones relacionadas