pushing UIViewController without Navigation Contro

2019-07-20 23:30发布

问题:

I was using that method for pushing another UIViewController in if condition :

initViewController *MW = [initViewController alloc];
MW = [self.storyboard instantiateViewControllerWithIdentifier:@"init"];
[self.navigationController pushViewController:MW animated:YES];

Now i've changed my architecture and i just removed my Navigation controller. That's why , these steps will not help me any longer due to no NavigationController exist. Now how can i push another ViewController without pressing button -(IBAction) . I just wanted to use it in Storyboard.

Regards.

回答1:

FYI : without UINavigationController You can't push to another Controller . You can produce a Controller using

PresentViewController

 [self presentViewController:objPortrit animated:YES completion:^{    }];

For Ex:

 initViewController *MW = [initViewController alloc];
   MW = [self.storyboard instantiateViewControllerWithIdentifier:@"init"];
    [self presentViewController:MW animated:YES completion:^{

            }];

EDIT:

For your comment : 

after producing the ViewController with PresentViewController, You need to dismiss it to produce another ViewController .

You can get over from this , something like this in their respective ViewController Use his method. :

 -(void)viewDidDisappear {
[self dismissModalViewControllerAnimated:YES];
}