Problem with presentPopoverFromRect and setPopoverContentSize in iOS7

To make popovers in iOS7 function properly, it seems that I need to do some workarounds, in the code below I am trying to understand why it is necessary to re-display a popover a second time. Without re-displaying, when in iOS7, the arrows indicate the wrong place, if enabled. Typically, an application works in landscape, so I wonder if this is related to the orientation and time of the animation. In addition, without re-displaying, the transparent panel zooms in about 500ms to fill the screen before the popover slides into place. With the re-display, the popover just clicks in the right place, as expected.

NSArray *currSysVer= [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];

if(self.showingKeyboard == NO) {
    if([[currSysVer objectAtIndex:0] intValue] > 6)
    {
        [selectPopover  presentPopoverFromRect:localField.frame inView:localField permittedArrowDirections:NO animated:NO];
    }
    else
    {
        [selectPopover  presentPopoverFromRect:localField.frame inView:localField permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
}

//Determine height and width of popover to fit all values
CGFloat width = 320;

if(multiSelect) {
    width = 450;
}

for(NSString *value in values) {

    CGSize size = [value sizeWithFont:[UIFont systemFontOfSize:23]];

    if(size.width > width) {
        width = size.width;
    }
}

CGFloat height = (44 * [values count] + 1) > 800 ? 800 : 44 * [values count] + 1;

if([[currSysVer objectAtIndex:0] intValue] > 6) {
    height += 6;
}

[selectPopover setPopoverContentSize:CGSizeMake(width, height + 36) animated:NO];

if(self.showingKeyboard == NO && [[currSysVer objectAtIndex:0] intValue] > 6) {
    [selectPopover  presentPopoverFromRect:localField.frame inView:localField permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
+4
2

, . , , , . , popover , :

permittedArrowDirections:(UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown)

, popover .

, .

0

, presentPopoverFromRect:, setPopoverContentSize:. UIPopoverController , , popover.

, popover, setPopoverContentSize: - presentPopoverFromRect:?

0

All Articles