Natan R.
Natan R.

Reputation: 5181

setPopoverContentSize not working

I have a UIPopoverController in a view, and the following method to update its CGSize:

-(void)updatePop:(CGSize)newSize
{
    NSLog(@"New Size: %@", NSStringFromCGSize(newSize));    
    [popoverSearch setPopoverContentSize:newSize animated:YES];
    NSLog(@"popoverContentSize: %@", NSStringFromCGSize(popoverSearch.popoverContentSize));
}

When the method runs, the console shows the following:

New Size: {320, 640}
popoverContentSize: {320, 409}

Does anyone have idea why it's happening? It happens specially in landscape...

Upvotes: 2

Views: 2259

Answers (1)

Chuck H
Chuck H

Reputation: 8266

I was having a similar problem in that I was unable to change the size of a popover controller during device rotation. I found the information that lead to my solution in a answer to a similar question.

Because I was presenting the popover from a Bar button, UIKit was "trying" to help by adjusting the size of the popover during rotation (because the position of the button might be different after a change to a different device orientation). Even though I knew exactly what size I wanted the popover to be in every case, it wasn't respecting my calls to setPopoverContentSize. My solution was to dismiss the popover in willAnimateRotationToInterfaceOrientation, then re-present the same popover in didRotateFromInterfaceOrientation after setting appropriate values for both contentSizeForViewInPopover and popoverContentSize. IHTH

Upvotes: 3

Related Questions