views:

1221

answers:

2

I have a UIPopoverController with a subclass UINavigationController. Both the parent and child views are UITableviews.

When i call parent view originally with contentSizeForViewInPopover = (320,480) it works great.

When i click into the child view i resize the popover to contentSizeForViewInPopover = (320,780)

When return back to the parent view i cannot get the popover to resize back to contentSizeForViewInPopover = (320,480). the popover stays at the (320,780) size.

Been trying everything but just missing something. Anyone know how resize the view with UIPopoverControllers in the above scenario?

Thanks in Advance!!

A: 

Hi there, I think I had the same problem and I solved it by setting the size for the view in the popover every time the view was about to appear. Like this:


-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

    self.contentSizeForViewInPopover = CGSizeMake(320, 444); //Set your own size
}

I hope this helps you.

Enrique R.
thanks for the input enrigue. originally i tried this and just doesnt seem to do anything. imagine, the parent popover opens at 320x480. then i select a row which pushes a "child" view inside the popover that is 320x720. if i click the back button my "parent" view is still 320x720.
Abbacore
Can you detect when they push the back button or when the previous view shows again after they touch the back button? If you can detect that then you can place the 'contentSizeForViewInPopover' in that part of the code.
Enrique R.
A: 

The contentSizeForViewInPopover property of the view controller only sets the default (initial) size of its containing UIPopoverController. To resize the UIPopoverController at an arbitrary time, you must set its popoverContentSize property. Note that popoverContentSize is a property of the UIPopoverController and not of the view controller (so you'll probably need a reference to the popover controller around).

To reset the popover's size every time a view controller becomes the top view controller of a UINavigationController, you can use the UINavigationControllerDelegate protocol methods:

navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (viewController == viewControllerToResize) {
        referenceToUIPopoverController.popoverContentSize = CGSizeMake(320,480);
    }
}
cristoper