Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8824437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:38:06+00:00 2026-06-14T06:38:06+00:00

How do I get my UIPopoverController to animate its size when its contained UINavigationController

  • 0

How do I get my UIPopoverController to animate its size when its contained UINavigationController pushes a new controller?

I have a UIPopover being displayed from a UIBarButtonItem in my iPad app. It contains a UINavigationViewController, which has a sort of settings window as its root view controller. The settings window is a subclass of UITableViewController (style set to grouped), and tapping any of its cells pushes different "chooser" view controllers on the nav controller that are also subclasses of UITableViewController.

For each of the chooser views, in viewDidAppear, I’m setting contentSizeForViewInPopover appropriately:

self.contentSizeForViewInPopover = CGSizeMake(320, self.items.count * 44);

But it doesn’t animate the change; when the navigation animation finishes, the popover snaps to the new height (width never changes from 320). Navigating backward animates the size change (accomplished with the technique from this answer), but forward never does.

I’ve tried obtaining a reference to the popover it’s in and using setPopoverContentSize:animated: but it doesn’t work. I’ve looked at other questions to no avail.

How do I get it to always animate the size change properly?

Update: I’ve set up a simple test project to try this out. It’s a tab bar application for iPad set up in Xcode. I added a tab bar item to the navigation bar in one of the view controllers. When that button is pressed, the controller presents a popover that contains a navigation controller that has a very simple UITableViewController subclass, called TestContentViewController, as its root view controller.

In viewDidLoad of that subclass, I randomly generate a number of items:

self.numItems = arc4random() % 10 + 3;

This is my number of rows; number of sections is 1. In cellForRowAtIndexPath I just set the cell’s label text and return it. When a row is selected, I generate another instance of the same class and push it on the stack.

Without doing anything at all with the contentSizeForViewInPopover property on any VC, the popover just goes to its maximum height and stays there no matter how many rows are in my table view.

If I set the size in viewDidAppear, like this:

-(void)viewDidAppear:(BOOL)animated
{
  self.contentSizeForViewInPopover = CGSizeMake(320, self.numItems * 44);
  [super viewDidAppear:animated];
{
  • When the popover first appears, it flashes very quickly to full height and then snaps to the height I set.
  • When a new controller is pushed on the navigation controller, it snaps to its height with no animation.
  • When I navigate back, if the VC that I’m popping to is taller than the one I’m popping from, it animates to the correct size. If what I’m popping to is smaller, it does nothing.

If I do the same thing but in viewWillAppear:

  • When the popover first appears, it’s full-height
  • When I first tap a row and get a new controller on the stack, it animates to a minimum of about 400px tall. When a new controller is pushed on the stack, if it needs more height it gets it. If not it stays at what it was before.

If I do the same thing in viewDidLoad, it’s basically the same as viewWillAppear except it appears at the right size at first.

I’ve tried setting the nav controller’s delegate to be the VC that presents the popover, and then set the popover’s height (setPopoverContentSize:animated:) in navigationController:didShowViewController:animated:, but the resultant height is off by a little bit. I think the size I set there needs to take into account the extra height of the navigation bar built into the top of the popover. And the animation when pushing a new controller on the stack is weird.

Update again: See here for the same problem solved with the newer UIPopoverPresentationController.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:38:07+00:00Added an answer on June 14, 2026 at 6:38 am

    Try to do the following for all UITableViewController, I tried it and it works for me!

    - (void)setSize:(BOOL)fake
    {
        CGSize view_size;
        int sections_height, rows_height;
    
        //if you dynamically change the number of visible rows
        //for example overriding numberOfRowsInSection:section
        //this can help you to evaluate the correct popover height
        int sections = [self.tableView numberOfSections];
        int rows = 0;
        for(int i = 0; i < sections; i++){
            rows += [self.tableView numberOfRowsInSection:i];
        }
        sections_height = sections * 30 /*section height*/;
        rows_height = rows * 44 /*row height*/;
    
        view_size = CGSizeMake(320 /*fixed width*/, sections_height + rows_height);
    
        if(fake){
            view_size.width -= 1;
            view_size.height -= 1;
        }
    
        [self setContentSizeForViewInPopover:view_size];
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        //...    
        [self setSize:FALSE];
    }
    
    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
        [self setSize:TRUE];
    }
    
    - (void)viewDidAppear:(BOOL)animated
    {
        [self setSize:FALSE];
        [super viewDidAppear:animated];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIPopoverController presented from a UIBarButtonItem. I have another UIBarButtonItem that is
I have a UIPopoverController with a subclass UINavigationController. Both the parent and child views
get / and inside controller I have action that depends on browser When I
So I have a UIPopoverController what houses my UINavigationController where I have my UITableViewController
Get class from div inside an li and add to the same li. The
I get this error while accessing a php script: W/System.err: Error reading from ./org/apache/harmony/awt/www/content/text/html.class
I am new to IOS and can't seem to get this to work ,
I have a table in a UIPopoverController , on viewDidAppear I check for the
Get the following error periodically in an IIS application: Failed to load resources from
I have a UITextField where I am implementing autocomplete in a UIPopoverController . I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.