Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push a view, go back and come back to the view?

I want to build an app for playing local audio files on the iPhone but I'm stuck with some of my codes. I'm wondering how you can push a view, come back to the uitableviewcontroller and use a button ( like the "NOW PLAYING" button in the media player) to come back to the view without pushing any new string into it..

THANK YOU

What should I change from my codes ?

in the 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

    }

in mPlayerViewController.m

-(IBAction) backtoplayer{
    myDetViewCont = [[mPlayerViewController alloc] initWithNibName:@"mPlayerViewController" bundle:nil];
}
like image 450
Alby Avatar asked Mar 16 '11 21:03

Alby


People also ask

How do I pop a ViewController in Swift?

You can do it by selecting the View Controller in Storyboard editor and clicking Editor -> Embed In -> Navigation Controller. Also make sure that you have your Storyboard Entry Point (the arrow that indicates which view controller is presented first) either pointing to Navigation Controller or before it.


1 Answers

If you have pushed a view onto the navigation controller, just pop it to review the view underneath.

That is, the view you push myDetViewCont should just be popped in the backtoplayer call.

- (IBAction)backToPlayer:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
like image 186
MarkPowell Avatar answered Oct 15 '22 18:10

MarkPowell