The popover's preferred size is only works if the height is greater than 320.
I have searched a lot to solve this issue. But didn't find any answer. Is there any minimum size that the popover should satisfy in iPad? If not, what i'm missing?
Code:
UIViewController *viewController = [subStoryboard instantiateViewControllerWithIdentifier:SMFormViewControllerSBID];
controller = [[UINavigationController alloc] initWithRootViewController:viewController];
SMFormViewController *formViewController = (SMFormViewController *)controller.topViewController;
formViewController.modalPresentationStyle = UIModalPresentationPopover;
formViewController.preferredContentSize = CGSizeMake(375, 320);
popController = [controller popoverPresentationController];
popController.permittedArrowDirections = UIPopoverArrowDirectionLeft;
popController.delegate = self;
popController.sourceView = tblDocDetails;
NSInteger section = [tblDocDetails numberOfSections] - 1;
CGRect rectCustomLoc = [tblDocDetails rectForFooterInSection:section];
popController.sourceRect = CGRectMake(rectCustomLoc.origin.x, rectCustomLoc.origin.y, 130, rectCustomLoc.origin.y/2);
[self presentViewController:controller animated:YES completion:nil];
Note:
I tried, adaptivePresentationStyleForPresentationController:
& adaptivePresentationStyleForPresentationController:
to return UIModalPresentationNone
.
My popover sometimes doesn't visible, because of the sourceRect
was incorrect.
Since I embedded ViewController in a Navigation Controller, preferredContentSize
should set to Navigation Controller.
controller.preferredContentSize = CGSizeMake(375, 100);
& in ViewController:
self.navigationController.preferredContentSize = contentsize;
And Changed sourceRect
to:
CGRect rectCustomLoc = [table rectForFooterInSection:section];
rectCustomLoc.size.width = sender.frame.size.width;
popController.sourceRect = rectCustomLoc;