防止UIPopover在iPhone 6上以横向显示为UIPageSheet

时间:2015-05-26 15:43:44

标签: objective-c iphone uisplitviewcontroller iphone-6-plus uitraitcollection

我正在尝试在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的弹限

1 个答案:

答案 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