Search code examples
iosipaduipopovercontrollerwindow-resize

UIPopoverController strange resize behavior


I developed a static library for iPhone using a UINavigationController & pushing some UIViewControllers.

I'm implementing a way to permit ipad developers to include my library to their iPad applications. To do so, I want to display my library controllers in a UIPopoverController whose size is the iphone one.

That's I have developed, but each time i'm pushing a new viewController, the Popover resizes itself a very strange way:

enter image description here

I've checked my view controllers (via interface builder), and the AutoResize behaviors are deactivated.

Anybody have a solution ?


Solution

  • The UIViewController that the UIPopoverViewController displays needs to set this property:

    contentSizeForViewInPopover
    

    to indicate its displaying size, and the UIPopoverViewController will get resized according to the value of that property. For example:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        self.contentSizeForViewInPopover = self.view.frame.size;
        // Do any additional setup after loading the view from its nib.
    }