Just upgrade to iOS17 to find that a year selector popover is no longer working on one of my onboarding screens. It opens with 0x0 size and at the top left of the screen instead of over the specified view. All I see is the drop shadow. Strangely the component backing it works fine in the rest of the app (over UITableViewController's as well).
I've tried:
- Playing with
translatesAutoresizingMaskIntoConstraints - overriding the
preferredContentSizegetter - trialing it with just a red square UIView with fixed size
- Fixed sized constraints on the popup tableview's Xib
Interestingly if I dont specify popoverPresentationController properties it treats it like a full sized modal window and it shows properly works.
The component:
class PopoverVC: UIViewController, UIPopoverPresentationControllerDelegate {
var contentVC: UIViewController?
var preferredSize: CGSize?
var sourceView: UIView?
var sourceRect: CGRect?
@objc
convenience init(contentVC:UIViewController, preferredSize:CGSize, sourceView:UIView, sourceRect:CGRect) {
self.init()
self.contentVC = contentVC
self.preferredSize = preferredSize
self.sourceView = sourceView
self.sourceRect = sourceRect
modalPresentationStyle = .popover
// Commenting out these makes it a full screen modal and works
popoverPresentationController!.permittedArrowDirections = [.left, .right]
popoverPresentationController!.sourceView = sourceView
popoverPresentationController!.sourceRect = sourceRect
popoverPresentationController!.delegate = self
}
override func viewDidLoad() {
view.frame = contentVC!.view.frame
view.addSubview(contentVC!.view)
contentVC!.willMove(toParent: self)
addChild(contentVC!)
preferredContentSize = preferredSize!
view.tintColor = .white
}
/** Reverts the iPhone/compact default of making it into an action sheet. */
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
}
...and the invoking code (ol' school!)...
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.frame];
[self presentViewController:self.yearPopover animated:YES completion:nil];
[yearListVC highlightSelectedYear];
It's also fine in iOS<=16....and again works fine elsewhere in the app. As far as I can tell the structuring of the onboarding screen isnt vastly different than places in the app where the component works fine (clearly there must be some difference)
Running out of ideas...suggestions greatly appreciated.