Search code examples
iosios14ios-keyboard-extension

iOS 14 only issue: images in keyboard extension no longer displays (but works fine in iOS 13)


I have an iOS keyboard extension that displays rows of UIImageViews in a scroll view.

Addendum, for clarity: the exact same codebase produces two very different results on two different iOS versions. There is no mention in the iOS 14 release notes for changes affecting keyboard extensions. Because of the differentiating results from iOS versions, I have no insight on what code to paste which may offer clues about what has caused this.

This question is open to those who may have insights or had experiences with iOS versions causing issues.

With the same codebase, on iOS 13, the rows of images show normally:

enter image description here

On the same device type with iOS 14, no images shows:

enter image description here


Solution

  • As user @thedp helpfully pointed out in the comments to the question, this is indeed an UIImageView issue specific to iOS 14 that was not included in the release notes.

    For easy browsing, here are the top resources I found:

    And the resolution?

    When the UIImage is initiated or being set, add:

    layer.contentsScale = image.scale
    layer.contents = image.cgImage
    

    That was the resolution.