I implemented SWRevealViewController in my project for Side menu item. Basically am app is kind of Music application. Songs from Home screen will remain playing continuously if the user in some other screen or in background. Am following this tutorial AppCoda (http://www.appcoda.com/ios-programming-sidebar-navigation-menu/)
- When the app launching the Home Screen will be launched also start to play song.
- If the user goes to another screen like playlist from the side menu item. The Home screen is in Stack and the song is playing perfectly. The Playlists screen is in Front.
- Again I go the Home screen from Side menu item. The new instance is creating instead of going to the already created Home screen. Now, am able to listen two songs at a time. One from first Home Screen and another one from new Home Screen.
This is happening for all screens. How can I solve this issue? I want only one screen from the stack instead of creating the same screen in many times.
Here is my Code from Side menu tableview Controller,
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 1) {
UINavigationController *navController;
if (indexPath.row == 0) {
ViewController *homeVC = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
navController = [[UINavigationController alloc] initWithRootViewController:homeVC];
[navController setViewControllers: @[homeVC] animated: YES];
} else if (indexPath.row == 1) {
SongsListViewController *songsListVC = [self.storyboard instantiateViewControllerWithIdentifier:@"SongsListViewController"];
navController = [[UINavigationController alloc] initWithRootViewController:songsListVC];
[navController setViewControllers: @[songsListVC] animated: YES];
} else if (indexPath.row == 2) {
PlayListViewController *songsListVC = [self.storyboard instantiateViewControllerWithIdentifier:@"PlayListViewController"];
navController = [[UINavigationController alloc] initWithRootViewController:songsListVC];
[navController setViewControllers: @[songsListVC] animated: YES];
}
[self.revealViewController setFrontViewController:navController];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
}
}
Looking forward your help. Thanks in advance.