Checkmark Not Showing Up On IPad In UITableView

- 1 answer

I want the user to be able to select a single row in a UITableView and then have that row show the Checkmark accessory. First to check how it looks in the UI, I added the checkmark through the XCode Interface Designer, like this;

Interface Designer

Ran it on the iPhone X Simulator and it works as expected.

iPhone X Simulator

But when I run it on the iPad Pro (12.9 inch) (2nd generation) Simulator it doesn't show up.

iPad Pro Simulator

So I thought that maybe the constraints were the issue, so I tried writing the widths of all the views that could be the problem to the console and they all returned 1024 so that is correct.

When I try setting the checkmark through code I have the same problem.

Am I missing something here?

EDIT: Screenshot with red borders on the cells. Simulator screen



Your issue is definitely about constraints and Auto Layout.

  • You should set constraints to superView for checkmark : trailing/top/bottom

    Horizontal spacing between the UILabel and the Checkmark.

    And Edit this last constraint to make it "Greater or equal" so that it will eventually grow with bigger screen. You will also want to change your content hugging priority.

  • Simpler solution : You could also use UIStackView in order to proportionally align your label and your checkmark regardless of the screen resolution.