iOS Development

In iOS 17, popover out of the blue rendering 0x0 measurement and misplaced over UITableViewController

Spread the love

Simply improve to iOS17 to search out {that a} yr selector popover is now not engaged on one in all my onboarding screens. It opens with 0x0 measurement and on the high left of the display as an alternative of over the required view. All I see is the drop shadow. Unusually the part backing it really works nice in the remainder of the app (over UITableViewController’s as properly).

I’ve tried:

  • Taking part in with translatesAutoresizingMaskIntoConstraints
  • overriding the preferredContentSize getter
  • trialing it with only a pink sq. UIView with fastened measurement
  • Mounted sized constraints on the popup tableview’s Xib

Curiously if I dont specify popoverPresentationController properties it treats it like a full sized modal window and it exhibits correctly works.

The part:

class PopoverVC: UIViewController, UIPopoverPresentationControllerDelegate {

    var contentVC: UIViewController?
    var preferredSize: CGSize?
    var sourceView: UIView?
    var sourceRect: CGRect?
    comfort init(contentVC:UIViewController, preferredSize:CGSize, sourceView:UIView, sourceRect:CGRect) {
        self.contentVC = contentVC
        self.preferredSize = preferredSize
        self.sourceView = sourceView
        self.sourceRect = sourceRect
        modalPresentationStyle = .popover

        // Commenting out these makes it a full display modal and works
        popoverPresentationController!.permittedArrowDirections = [.left, .right]
        popoverPresentationController!.sourceView = sourceView
        popoverPresentationController!.sourceRect = sourceRect
        popoverPresentationController!.delegate = self
    override func viewDidLoad() {
        view.body = contentVC!.view.body
        contentVC!.willMove(toParent: self)
        preferredContentSize = preferredSize!
        view.tintColor = .white
    /** Reverts the iPhone/compact default of creating it into an motion sheet. */
    func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
        return .none

…and the invoking code (ol’ faculty!)…

    NSDictionary* questionDict = self.questionsArray[indexPath.section];
    PXTextEntryCell* cell = (PXTextEntryCell*)[self.tableView cellForRowAtIndexPath:indexPath];
    PXYearList* yearListVC = [[PXYearList alloc] initWithNibName:@"PXYearList" bundle:nil];
    yearListVC.delegate = self;
    yearListVC.cellIndexPath = indexPath;
    yearListVC.selectedYear = [(NSNumber *)[self.demographicData answerWithQuestionId:questionDict[@"questionID"]] integerValue];

    self.yearPopover = [[PopoverVC alloc] initWithContentVC:yearListVC preferredSize:CGSizeMake(120, 300) sourceView:cell.contentView sourceRect:cell.contentView.body];
    [self presentViewController:self.yearPopover animated:YES completion:nil];
    [yearListVC highlightSelectedYear];

It is also nice in iOS<=16….and once more works nice elsewhere within the app. So far as I can inform the structuring of the onboarding display isnt vastly completely different than locations within the app the place the part works nice (clearly there should be some distinction)

Working out of concepts…solutions significantly appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *