Present View Controller not working with ios 9

Present view controller is not working with ios 9,
when I press the button it not redirected to present view controller.

Why this happens ?

  • presentViewController does not show Tab Bar or Navigation Bar
  • Closing only the ImagePicker and passing image to ScrollViewController
  • push view controller after dismissing presented view controller
  • Refreshing Parent ViewController after dismissing ModalViewController
  • Swift presentViewController
  • Dismissing a ViewController lower in the stack does not behave as expected
  • I had tried the below code

     RegistrationViewController * viewController =[[UIStoryboard storyboardWithName:@"Registration" bundle:nil] instantiateViewControllerWithIdentifier:@"RegistrationViewController"];
     [self presentViewController:viewController animated:YES completion:nil];
    

    I had also tried the below code

     UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Registration"
                                                             bundle:nil];
     RegistrationViewController *add =
     [storyboard instantiateViewControllerWithIdentifier:@"RegistrationViewController"];
     [self presentViewController:add animated:YES completion:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [self presentViewController:add
                                   animated:YES
                                 completion:nil];
            });
      }];
    

    Edit

    My complete code here. I am using Xcode 7 and running it with ios 9

    #import "LoginViewController.h"
    #import "RegistrationViewController.h"
    
    @interface LoginViewController ()
    
    @end
    
    @implementation LoginViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    
    - (IBAction)actionRegistrationClicked:(id)sender
    {
        RegistrationViewController * viewController =[[UIStoryboard storyboardWithName:@"Registration" bundle:nil] instantiateViewControllerWithIdentifier:@"RegistrationViewController"];
         [self presentViewController:viewController animated:YES completion:nil];
    
    }
    @end
    

    Registration view controller

    #import "RegistrationViewController.h"
    
    @interface RegistrationViewController ()
    
    @end
    
    @implementation RegistrationViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
    

    4 Solutions Collect From Internet About “Present View Controller not working with ios 9”

    Make sure the presentedViewController is nil. If presentedViewController is not nil change the code to following.

    RegistrationViewController * viewController =[[UIStoryboard storyboardWithName:@"Registration" bundle:nil] instantiateViewControllerWithIdentifier:@"RegistrationViewController"];
    
    if ([self presentedViewController]) {
        [[self presentedViewController] dismissViewControllerAnimated:NO completion:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [self presentViewController:viewController animated:YES completion:nil];
            });
        }];
    } else {
        [self presentViewController:viewController animated:YES completion:nil];
    
    }
    

    Sometimes a bug occurs with main loop, try to present that way

    RegistrationViewController *viewController = [[UIStoryboard storyboardWithName:@"Registration" bundle:nil] instantiateViewControllerWithIdentifier:@"RegistrationViewController"];
    
    dispatch_async(dispatch_get_main_queue(), ^{
       [self presentViewController:viewController animated:YES completion:nil];
    });
    

    try viewDidAppear in

      -(void)viewDidAppear:(BOOL)animated{ 
             [self presentViewController:viewController animated:YES completion:nil];
        }
    

    Try the below code:

    RegistrationViewController * viewController = [[self.storyboard instantiateViewControllerWithIdentifier:@"RegistrationViewController"];
    
    [self presentViewController:viewController animated:YES completion:nil];