LoginSignup
2

More than 5 years have passed since last update.

UIPopoverController回転時に位置をセンタリングする

Last updated at Posted at 2014-11-04

UIPopoverController表示後、iPadの向きを縦・横に変えると位置がおかしくなります。
その場合、UIPopoverControllerのdelegateに下記を実装すると、向き変更後にセンタリングされます。

- (void)popoverController:(UIPopoverController *)popoverController willRepositionPopoverToRect:(inout CGRect *)rect inView:(inout UIView *__autoreleasing *)view
{
    // popOverの位置を更新する
    *rect = CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/2, 1, 1);
}

※iOS7以降

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2