为了让 iOS7 中的弹出框正常运行,看来我必须采取一些解决方法,在下面的代码中,我试图理解为什么需要第二次重新显示弹出框。在 iOS7 中没有重新显示的情况下,如果打开箭头,它们会指向错误的位置。通常应用程序在横向运行,所以我想知道这是否与动画的方向和时间有关。同样,在没有重新显示的情况下,透明窗格会在大约 500 毫秒内缩小以在弹出框滑入到位之前填充屏幕。随着重新显示,弹出框就像预期的那样卡在正确的位置。
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];
}