title: How do I perform continuous orientation detection in ios?
body: <p>I have is a simple if statement to detect an orientation and perform an action.  This works well, but it only works the first time and it can't detect it again.  </p>
  
  <p>Does this <code>void</code> only get called once and if so, how can I change this around to constantly check? </p>
  
  <p>Would I need to move some to <code>viewDidLoad</code>?    </p>
  
  <pre><code>- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
      {
          [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
  
          if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
  
          {
              [self.navigationController pushViewController:graphView animated:YES];
  
          }
  
              else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
              {
                  [self.navigationController pushViewController:graphView animated:YES];
              }
  
              else if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
              {
                  [self.navigationController popToRootViewControllerAnimated:YES];
                  NSLog(@"portrait");
              }
  
              else
              {
                  [self.navigationController popToRootViewControllerAnimated:YES];
  
              }
  
          }
  </code></pre>