title: Change Orientation in iOS 9
body: <p>My app will be launched in Landscape,only one view can change to Portrait, in which there is a button,I click this button to change the orientation to Portrait.
  It performed as expected on iPad(iOS 8.4,Deployment target: 7.0),and I made an iPhone version,in which I just made some adjust on UI,and it runs on iPhone 6 Plus simulator(Base SDK: 9.1,Deployment target: 7.0),but the button for chagning orientation doesn't work. 
  And I want to know how to implement this in iOS 9;
  The Below is my code:</p>
  
  <pre><code>- (void)changeOrientation
  {
      UIInterfaceOrientation orientation = [[UIApplication sharedApplication]  statusBarOrientation];
  
  
       if(orientation==UIInterfaceOrientationLandscapeLeft||orientation==UIInterfaceOrientationLandscapeRight){
  
  
  
      NSNumber *value = [NSNumber  numberWithInt:UIInterfaceOrientationPortrait];
  
      if (orientation==UIInterfaceOrientationLandscapeLeft) {
  
          value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
      }else {
  
          value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];
      }
  
      [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
  
      [[NSNotificationCenter defaultCenter] postNotificationName:@"ScreenToPortrait" object:nil];
  }else{
  
  
  
      NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
      if (orientation==UIInterfaceOrientationPortrait) {
          value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
      }else {
          value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
      }
  
  
      [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
  
      [[NSNotificationCenter defaultCenter] postNotificationName:@"ScreenToLandscapeLeft" object:nil];
  }
  
      [UIViewController attemptRotationToDeviceOrientation];
  </code></pre>
  
  <p>}</p>