title: Difficulties changing between viewControllers in xcode
body: <p>I have 3 different viewControllers. first one is the main page where you will see many thumbnail of images. Second controller will only open when an image is clicked. Last ViewController is the login which opens when the user is not logged in but trying to view the second controller or clicked login from the main controller. In the login controller I have a back button to go to main page. Remember the user can access login from two different ways. by clicking on the image or clicking login in the main controller directly. So the issue is the back button does work properly. When the login page is accessed from the main controller directly, then the back button works fine it takes you to the main page. However, if you click on any of the thumbnails the second controller will try to open but since your not logged in the login page will show and when you click the back button to send you to the main controller, it won't go to main instead it will reload the same page and you kind of stock in a loop you have to login or exit the app. any ideas why?</p>
  
  <p>The First ViewController Identifier is set to "mainImages". </p>
  
  <pre><code>- (IBAction)backToMain:(id)sender {
  
       [self dismissViewControllerAnimated:NO completion:nil];
  
       NSString * storyboardName = @"MainStoryboard";
       UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
       UIViewController * MI = [storyboard instantiateViewControllerWithIdentifier:@"mainImages"];
       UINavigationController *navController = self.navigationController;
  
       if (navController) {
           [navController pushViewController:MI animated:NO];
       }
  
  }
  </code></pre>
  
  <p>I also tried this but no luck:</p>
  
  <pre><code>[self dismissViewControllerAnimated:NO completion:nil];
  
  UIViewController * MI = [self.storyboard instantiateViewControllerWithIdentifier:@"mainImages"];
  [self presentViewController:MI animated:NO completion:nil];
  </code></pre>