title: Repositioning UIPopoverController on device rotation
body: <p>I'm trying to re-position a popover view when the device is rotated. I use this code to create the popover:</p>
  
  <pre><code>        settingsViewCtrl = storyboard.instantiateViewControllerWithIdentifier("settingsViewCtrl") as SettingsViewCtrl;
          settingsPopoverCtrl = UIPopoverController(contentViewController: settingsViewCtrl);
          settingsPopoverCtrl.delegate = self;
          let m:CGFloat = min(view.frame.width, view.frame.height);
          let s:CGSize = CGSizeMake(m - 100, m - 100);
          let r:CGRect = CGRectMake(view.frame.width * 0.5, view.frame.height * 0.5, 1, 1);
          settingsPopoverCtrl.setPopoverContentSize(s, animated: true);
          settingsPopoverCtrl.presentPopoverFromRect(r, inView: view, permittedArrowDirections: nil, animated: true);
  </code></pre>
  
  <p>And I use <code>willRepositionPopoverToRect</code> in my delegate ...</p>
  
  <pre><code>func popoverController(popoverController:UIPopoverController!, willRepositionPopoverToRect rect:UnsafeMutablePointer&lt;CGRect&gt;, inView view:AutoreleasingUnsafeMutablePointer&lt;UIView?&gt;)
  {
      if (settingsPopoverCtrl != nil &amp;&amp; settingsViewCtrl != nil)
      {
          let r:CGRect = CGRectMake(self.view.frame.width * 0.5, self.view.frame.height * 0.5, 1, 1);
          settingsPopoverCtrl.presentPopoverFromRect(r, inView: self.view, permittedArrowDirections: nil, animated: true);
      }
  }
  </code></pre>
  
  <p>But that can't be it since when I rotate the device I'm getting the warning:
  <strong>Application tried to represent an active popover presentation: </strong>
  and the popover also isn't repositioned.</p>
  
  <p>How do I get to apply and update positioning CGRect in willRepositionPopoverToRect so that the popover view updates? Would it be possible to modify the provided <code>rect:UnsafeMutablePointer&lt;CGRect&gt;</code> and give it back to the popover?</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>According to the docs (<a href="https://developer.apple.com/library/ios/documentation/uikit/reference/UIPopoverControllerDelegate_protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIPopoverControllerDelegate/popoverController%3awillRepositionPopoverToRect%3ainView%3a" rel="nofollow">https://developer.apple.com/library/ios/documentation/uikit/reference/UIPopoverControllerDelegate_protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIPopoverControllerDelegate/popoverController%3awillRepositionPopoverToRect%3ainView%3a</a>):</p>
  
  <blockquote>
    <p>If you want to propose a different rectangle for the popover, put the
    new value in this parameter.</p>
  </blockquote>
  
  <p>So the question is: How do I put the new value into this rect?</p>