我正在尝试在popOver
内部显示UISlider
,以允许用户控制textSize
的{{1}}。
我是这样做的:
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
除了景观中的iPhone 6 Plus(即紧凑高度)之外,所有设备上的一切都能正常工作,这会将- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
return UIModalPresentationNone;
}
显示为popover
注意:我在UIPageSheet
的{{1}} <{1}}中显示UIbarButtonItem
的弹限
答案 0 :(得分: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
。