Reputation: 10961
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?
Upvotes: 0
Views: 212
Reputation: 10961
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.
Upvotes: 0
Reputation: 9533
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
Upvotes: 0