ios13xcode11

Assert Current fallback trait collection contains one or more unspecified traits:


Once our app is run on iOS13 then the log is full of wried assertions. Anybody some tips how to remove it?

2019-09-19 08:05:43.528382+0200 Ts-2-cz-test[56066:20590106] [Assert] Current fallback trait collection contains one or more unspecified traits: {(
    "_UITraitNameDisplayScale",
    "_UITraitNameDisplayCornerRadius",
    "_UITraitNameSemanticContext",
    "_UITraitNameUserInterfaceLevel",
    "_UITraitNamePresentationSemanticContext",
    "_UITraitNameVibrancy",
    "_UITraitNameDisplayGamut",
    "_UITraitNameDebugHighlight",
    "_UITraitNamePreferredContentSizeCategory",
    "_UITraitNameTouchLevel",
    "_UITraitNameAccessibilityContrast",
    "_UITraitNameLegibilityWeight"
)}; traitCollection: <UITraitCollection: 0x7fb4ce32ad20; HorizontalSizeClass = Compact>; currentFallbackEnvironment: <UIView: 0x7fb46c421d80; frame = (0 0; 1024 1366); autoresize = W+H; layer = <CALayer: 0x7fb46c421ef0>>

Solution

  • I had the same issue here because I was overriding the traitCollection property (which is not recommended by Apple but I didn't find any other solution in my case) and the new traitCollection I returned has many unspecified traits (as the error message said).

    So now I return a new traitCollection object but I initialize it by adding super.traitCollection. So in my view controller I have something like:

    public override var traitCollection: UITraitCollection {
        var newTraitCollection: [UITraitCollection] = [super.traitCollection]
        // I need to force size class on iPad
        if UIDevice.current.userInterfaceIdiom == .pad {
            newTraitCollection += [UITraitCollection(verticalSizeClass: .regular), UITraitCollection(horizontalSizeClass: .compact)]
        }
        return UITraitCollection(traitsFrom: newTraitCollection)
    }