I have added a navigation bar programmatically to the MPMoviePlayerViewController. How to add a backbar button item to the navigation bar to navigate to previous view controller?
-(IBAction)playA1{
NSURL * urlA1 = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"A1"ofType:@"mp4"]];
MPMoviePlayerViewController *playercontrollerA1 = [[MPMoviePlayerViewController alloc] initWithContentURL:urlA1];
playercontrollerA1.moviePlayer.repeatMode = MPMovieRepeatModeOne;
// [self presentMoviePlayerViewControllerAnimated:playercontrollerA1]; //comment out if navigation bar code is added
playercontrollerA1.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
// ADD UI NAVIGATION BAR in EMBEDDED CONTROL STYLE
playercontrollerA1.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
UINavigationController *movieNavController = [[UINavigationController alloc] initWithRootViewController:playercontrollerA1];
playercontrollerA1.navigationItem.title=@"APone";
playercontrollerA1.navigationController.navigationBar.tintColor = [UIColor blackColor];
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(favouriteButtonClicked:)];
playercontrollerA1.navigationItem.rightBarButtonItem = button;
[self presentViewController:movieNavController animated:YES completion:nil];
}
I thing you're using UINavigationController as wrong method. When you call presentViewController passing UINavigationController as a ViewController you aren't "navigating". You're just asking for show a viewcontroller.
Is "self" a UIViewController right? If yes, change this to UINavigationController and call pushViewController instead UIViewController's presentViewController method.