I have a UIPopoverController with navigationController and bunch of subviews. The size of the popover is set just before it's shown like this:
[self.myPopover setPopoverContentSize:CGSizeMake(320, 500)];
That works fine. The popover is shown with adjusted size. When another view is pushed on navigation stack the size of a popover is set again - need different height - in viewWillAppear method:
self.contentSizeForViewInPopover = CGSizeMake(320, 700);
This also works fine. When I go back to a previous view the size does not change.
I added the same call in viewWillAppear in first view but the view does not resize.
How can I manage resizing of popover when navigating between views?
Create custom titles, prompts, and buttons in your app’s navigation bar. Use UINavigationBar to display your app’s navigational controls in a bar along the top of the iOS device’s screen.
Each time the top-level view controller changes, the navigation controller updates the navigation bar accordingly. Specifically, the navigation controller updates the bar button items displayed in each of the three navigation bar positions: left, middle, and right. Bar button items are instances of the UIBarButtonItem class.
@MainActor class UINavigationController : UIViewController A navigation controller is a container view controller that manages one or more child view controllers in a navigation interface. In this type of interface, only one child view controller is visible at a time.
When the active view controller changes, the navigation controller updates the toolbar items to match the new view controller, animating the new items into position when appropriate.
I use this hack:
- (CGSize)contentSizeForViewInPopover
{
return CGSizeMake(320, 200);
}
- (void) forcePopoverSize
{
CGSize currentSetSizeForPopover = self.contentSizeForViewInPopover;
CGSize fakeMomentarySize = CGSizeMake(currentSetSizeForPopover.width - 1.0f,
currentSetSizeForPopover.height - 1.0f);
self.contentSizeForViewInPopover = fakeMomentarySize;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self forcePopoverSize];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
CGSize currentSetSizeForPopover = self.contentSizeForViewInPopover;
self.contentSizeForViewInPopover = currentSetSizeForPopover;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With