Media Items in JSQMessageViewController's Collection cells are not showing in IOS 14
Asked Answered
D

2

9

I am using JSQMessageViewController and I am facing the issue (only in ios14) that i cant see media items like Images, Video and Audio in device though these views are generating debug view hierarchy. See below attached image:-

debug view hierarchy screenshot:

enter image description here

here is the description of UIImage inside collection view cell: <UIImageView: 0x7fe7d6d95b30; frame = (20 8; 177 131); clipsToBounds = YES; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x600001ce4ec0>>

here is the screenshot attached of screen:

enter image description here

You can see the view has generated space for image, but its not showing up!

Is anyone facing this issue? how can i solve this problem. This issue is occurring in iOS 14, it works perfectly in iOS 13.

Demarche answered 21/9, 2020 at 10:15 Comment(1)
JSQMessageViewController hasn't been updated for more than 4 years and is no longer supported. Maybe you can try MessageKit instead: github.com/MessageKit/MessageKitHel
A
23

You need to overwrite in JSQMessagesMediaViewBubbleImageMasker.m
method - (void)jsq_maskView:(UIView *)view withImage:(UIImage *)image and change line:

view.layer.mask = imageViewMask.layer;

to be

view.maskView = imageViewMask;

I suggest you to use category for that. For me that was solution.

Aleksandr answered 24/9, 2020 at 13:20 Comment(1)
Thanks, @Aleksandr This solution worked for me but I want to confirm that do we need to add a check for #available(iOS 14.0, *) before adding this line?Crinkleroot
H
4

I would like to suggest to change like as follows along with the Vladimir answer for backward compatibility:

if (@available(iOS 14.0, *)) {
    view.maskView = imageViewMask;
} else {
    view.layer.mask = imageViewMask.layer;
}
Hufuf answered 25/11, 2020 at 5:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.