Pregunta

Quiero crear 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 puede presionar una vista, volver al UITableViewController y usar un botón (como el botón "ahora jugando" en el reproductor multimedia) para volver a la vista sin presionar ninguna cadena nueva en él.

GRACIAS

¿Qué debo cambiar de mis códigos?

En 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];
}
¿Fue útil?

Solución

Si ha impulsado una vista al controlador de navegación, simplemente llévelo para revisar la vista debajo.

Es decir, la vista que presionas myDetViewCont Debería ser aparecido en el backtoplayer llamar.

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

Otros consejos

Para agregar a lo que dijo Mark.

Una vez que haya ViewControllerAnimated y el usuario desea volver a impulsar el mismo controlador, solo necesita mantener el mplayerviewController en lugar de liberarlo.

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top