I found this thread, but it still doesn't fix my problem. UIPopoverController automatically resizing to max height on pushViewController
I have a UIPopoverController that pushes a navigationcontroller. When I present this popover, I set the contentSizeForPopover to 340,340. That works fine. In the popover, I have a button, that pushes a new UITableViewController into the already existing UIPopoverController (code below for the tableViewController).
UITableViewController *contentView = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
contentView.tableView.delegate = self;
contentView.tableView.dataSource = self;
[self.navigationController pushViewController:contentView animated:YES];
[contentView release];
When the tableView gets pushed, the height grows to the max height of the iPad. When I press the back button, the height still is at the max height and does not go back to the 340,340 height that was defined when the UIPopoverController was originally created. Is there a way to set this value again for the new tableView I created? Thanks.
All that you have to do is:
-In the viewWillAppear method of the popOvers contentView, add the snippet given below. You will have to specify the popOver's size first time when it is loaded.
In my experience with
UIPopoverController
objects, the popover seems to use the maximum height whenever new content is added to the popover. I send the popover controller asetPopoverContentSize:animated:
message every time I change the content, which of course requires me to keep a reference to that popover controller in every object that may cause the popover to resize. You could add that message send right after your sample code in your question to keep the popover from resizing, but it may still resize when you pop off this view from theUINavigationController
stack, so another message send may be needed. Maybe each view controller that may appear in the popup will send thesetPopoverContentSize:animated:
message in itsviewWillAppear:
method. Each will also have a reference to the popover controller.