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];
精彩评论