2

我正在尝试显示popOver带有UISlider内部的 a,以允许用户控制textSizea 的WKWebView

这是我的做法:

MYCustomViewController *popoverContent = [[self storyboard] instantiateViewControllerWithIdentifier:@"MYCustomViewController"];
    popoverContent.delegate = self;
    popoverContent.modalPresentationStyle = UIModalPresentationPopover;
    UIPopoverPresentationController *popover = popoverContent.popoverPresentationController;
    popoverContent.preferredContentSize = CGSizeMake(220, 40);
    popover.delegate = self;
    popover.barButtonItem = (UIBarButtonItem *)sender;

    [self presentViewController:popoverContent animated:YES completion:nil];

在自定义中ViewController,我只是添加了一个委托来获取UISlider

我也实现了这个方法:

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
  return UIModalPresentationNone;
}

除了 iPhone 6 Plus 在横向(即紧凑高度)之外,所有设备都可以正常工作,它显示popoverUIPageSheet

注意:我在 a 中展示了aUIbarButtonItem中的弹出框detailViewControllerUISplitViewController

4

1 回答 1

1

我通过实施@Joshua 建议的新adaptivePresentationStyleForPresentationController:traitCollection:方法解决了这个问题UIAdaptivePresentationControllerDelegate:

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection {
    // This method is called in iOS 8.3 or later regardless of trait collection, in which case use the original presentation style (UIModalPresentationNone signals no adaptation)
    return UIModalPresentationNone;
}

UIModalPresentationNone告诉演示控制器使用原始演示样式,在您的情况下将显示popover.

于 2015-05-27T12:50:13.017 回答