Reputation: 31
As shown above, when the landscape UIPopoverPresentationController to be such a display
Now this problem only on the 5.5 -inch phones (landscape)
On the 4.7 -inch phones will display correctly,The following figure:
This is my source code:
- (void)buttonClick:(UIButton *)sender{
self.buttonPopVC = [[PopoverViewController alloc] init];
self.buttonPopVC.modalPresentationStyle = UIModalPresentationPopover;
self.buttonPopVC.popoverPresentationController.sourceView = _button;
self.buttonPopVC.popoverPresentationController.sourceRect = _button.bounds;
self.buttonPopVC.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
self.buttonPopVC.popoverPresentationController.delegate = self;
[self presentViewController:self.buttonPopVC animated:YES completion:nil];
}
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{
return UIModalPresentationNone;
}
- (BOOL)popoverPresentationControllerShouldDismissPopover:(UIPopoverPresentationController *)popoverPresentationController{
return NO;
}
- (CGSize)preferredContentSize {
if (self.presentingViewController && self.tableView != nil) {
CGSize tempSize = self.presentingViewController.view.bounds.size;
tempSize.width = 150;
CGSize size = [self.tableView sizeThatFits:tempSize];
return size;
}else {
return [super preferredContentSize];
}
}
- (void)setPreferredContentSize:(CGSize)preferredContentSize{
super.preferredContentSize = preferredContentSize;
}
Could you tell me the solution?Thank you very much!
Upvotes: 1
Views: 253
Reputation: 153
Implement the traitCollection
variation of the UIAdaptivePresentationControllerDelegate
delegate method:
adaptivePresentationStyleForPresentationController
-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
traitCollection:(UITraitCollection *)traitCollection
{
return UIModalPresentationNone;
}
Either instead of, or with the one you have already:
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{
return UIModalPresentationNone;
}
Upvotes: 1