Question

enter image description here

enter image description here

Hello, I have UITableView with static content embedded in UIScrollView so I have just set size in popover:

- (CGSize)contentSizeForViewInPopover
{    
    return CGSizeMake(600, 670);
}

but, I got different popover heights (see attachments). In IOS4.3 height is bigger than in IOS5. I don't want to check IOS version and increase/decrease height.

Please advice.

Thanks

Was it helpful?

Solution

As far as I know, when using the navigation controller as popover contents, you have to

  1. set the contentSizeForViewInPopover on the root controller (or anyone that is being shown as the first). (Don't try to set size on the navigation controller).

  2. whenever you push/pop controllers and you want the popover size changed for the new controller on the stack, call setPopoverContentSize:animated: explicitly. A UINavigationControllerDelegate is good for this.

OTHER TIPS

You can dynamically calculate the height of your popover based on the height of your tableview and overriding contentSizeForViewInPopoverView like this:

- (CGSize)contentSizeForViewInPopoverView {
    CGFloat width = 200.0; // Currently no way to obtain the width dynamically, only height.
    CGRect rect = [self.tableView rectForSection:[self.tableView numberOfSections] - 1];
    CGFloat height = CGRectGetMaxY(rect);
    return (CGSize){width, height};
}

This assumes you have 1 section. If you have more, you just need to use rectForSection to determine the height of each section and add them up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top