开发者

How do you set the content size of a UIPopoverController?

I'm showing a view in a popover. When I click a button in this view, another view will be pushed into the开发者_如何学C popover using a navigation controller. While pushing, the height of the popover gets extended. How do I retain the same popover height?


In all your view controllers, override -contentSizeForViewInPopover and return the same size in all of them.


-contentSizeForViewInPopover is deprecated as of iOS 7, and does not seem to work in iOS 8.1. (I'm not sure when it stopped working.) The new method is to set the preferredContentSize, perhaps like this:

    MyPopoverViewController *myPopoverViewController = [[MyPopoverViewController alloc] initWithNibName: @"MyPopoverViewController" bundle: nil];
    myPopoverViewController.preferredContentSize = CGSizeMake(186, 160);

    self.myPopover = [[UIPopoverController alloc] initWithContentViewController: myPopoverViewController];
    myPopover.delegate = self;

    [myPopover presentPopoverFromRect: self.myButton.frame inView: self.view permittedArrowDirections: UIPopoverArrowDirectionAny animated: YES];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜