0

this is the screen shot of storyboard

I'm using SWRevealViewController and trying to pushing other view controllers by using this code:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"main" bundle:nil];
MyprofileQRsViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"SBMyprofileDetails"];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[navController setViewControllers: @[rootViewController] animated: YES];

[self.revealViewController setFrontViewController:navController];
[self.revealViewController setFrontViewPosition: FrontViewPositionRight animated: YES];

Its working well but i can't pop that view controller to previous view controller.. I used all basic popViewcontrollers code still not working. I just can't figure it out what to do. please any body has the trick what to do the reply please.. thanks in advance....

Ekta Padaliya
  • 5,743
  • 3
  • 39
  • 51
Dev Andy
  • 1
  • 2

3 Answers3

0

Please use the pushFrontViewController: in place of setFrontViewController:

The code is like this:

[revealController pushFrontViewController:frontController animated:YES];

It may helpful to you.

After that you can pop from the view controller.

Janmenjaya
  • 4,149
  • 1
  • 23
  • 43
Sanjukta
  • 1,057
  • 6
  • 16
0

You can Navigate you app to another viewControllers using below code

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
// here you need to create storyboard ID of perticular view where you need to navigate your app 
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"viewContIdentifire"];

// if use presentViewController this will not enables you to go back to previous view
[self presentViewController:vc animated:NO completion:nil];
                    **// OR**
// using pushViewController lets you to go back to the previous view
[self.navigationController pushViewController:vc animated:YES];

Note: use one of those methods presentViewController or pushViewController to navigate.


To handle pop back using popToRootViewControllerAnimated, popToRootViewControllerAnimated and popToRootViewControllerAnimated methods according to UI stack.

// this takes your app to the root view controller
[self.navigationController popToRootViewControllerAnimated:YES];

// this will takes you to the previous view loaded in stack
[self.navigationController popViewControllerAnimated:YES];

// this takes to any view controller, use accordingly 
[self.navigationController popToViewController:yourViewControllerName animated:YES];
jayess
  • 49
  • 6
vaibhav
  • 4,038
  • 1
  • 21
  • 51
0

Firstly, embed a navigation controller to your initial view controller and hide it's navigation bar from storyboard then write code for push view controller.

It will work perfectly in both cases push and pop view controller.

MyprofileQRsViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"SBMyprofileDetails"];
[self.navigationController pushViewController:rootViewController  animated:YES];
Narendra
  • 26
  • 3