Search code examples
swiftxcodeswift4xcode12

Xcode 12: TableView Cell image too big and covering text


I made some custom tableview cells and while everything else with them works, the images are really big and I cant get them any smaller.

enter image description here

I did this and its still flooding: I added height and width constraints and a 10 constraint to the left of the ImageView, and selected these settings

enter image description here

enter image description here

enter image description here


Solution

  • I can suggest a few things you can try to achieve it. I have illustrated 1 & 2 on the attached image:

    enter image description here

    • Suggestion 1 is to make sure there is no ambiguity or constraint collision. It seems you have set two constraints for the width of your image. You might be setting it to be 'greater than' the width you want it to be.
    • Suggestion 2 is to also provide a constraint between the image view and your label view for the heading in order to prevent an overlap.
    • Suggestion 3 is to make sure that your imageView has a setting of "Clips to bounds' checked on the inspector.
    • Suggestion 4 Change your content mode to Aspect Fill instead of Aspect Fit
    • Suggestion 5 Complete your constraints, make sure everything is blue. I don't see top and leading constraint. This will help remove any ambiguity.
    • Suggestion 6 Use the view debugger, see what constraint values are being used, and the debugger will also show you hierarchies and view layers, which will give you more idea of what is going on.