0

If I present a view controller as a popover on iPad (by setting its modalPresentationStyle to .popover), it will report its horizontal size class as .compact. But if I run the same code in a Catalyst app, the view controller in the popover reports a horizontal size class of .regular. Compact is what I expect. Setting overrideTraitCollection on the popoverPresentationController of the view controller before I present it works to make the size class regular on iPad, but it won't make it compact on Catalyst.

How can I make a view controller in a popover correctly report a compact horizontal size class in Catalyst?

2 Answers 2

0

I would assume the Catalyst authors set the default to .regular on Macs since popovers can be a lot bigger in general.

If you want to override it just on Macs I’d use an #ifdef, eg:

#if targetEnvironment(macCatalyst)
// set ‘overrideTraitCollection’ so it forces '.compact’ on the popover
#endif
1
  • overrideTraitCollection on the popover presentation controller doesn't do anything on Catalyst, sadly. May 30, 2021 at 22:37
0

I asked an Apple engineer this in a WWDC 2021 lab on Catalyst and he said it's a bug. I've filed it as Feedback FB9124431.

2
  • Any update on this? Nov 23, 2021 at 16:18
  • @VictorEngel Nope. Still broken in Monterey 12.0.1. Nov 24, 2021 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.