1

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

dylanvdb
  • 106
  • 18
  • 1
    check your tableView frame, maybe his width is bigger than you think – Reinier Melian Feb 16 '18 at 13:43
  • ipad 768/1024 width is 768 – Shehata Gamal Feb 16 '18 at 13:50
  • @Sh_Khan iPad Pro 12.9-inch logical resolution is 1024 x 1366 px according to the iOS Design Specifications. – dylanvdb Feb 16 '18 at 14:23
  • @ReinierMelian In the view section of the Size inspector it says it has a width of 375 which is locked and changes when I select a different "View as ..." so I don't think that's it, thanks for your reply though. – dylanvdb Feb 16 '18 at 14:49
  • 1
    in debug mode? @DylanvandenBrink please add `cell.layer.borderWidth = 1` and `cell.layer.borderColor = UIColor.red.cgColor` and post the screenShot – Reinier Melian Feb 16 '18 at 14:51
  • @ReinierMelian I posted the screenshot in the original question, looks like the cells/tableview is too wide for the view. So it must be the constraints right? I did fiddle around with them a lot because it is in a scrollview and couldn't get it to work. – dylanvdb Feb 16 '18 at 14:58
  • As I first told you @DylanvandenBrink your issue is related to autolayout – Reinier Melian Feb 16 '18 at 14:59
  • @DylanvandenBrink call for TableView.reloadData() in viewDidAppear instead and let me know if solves your issue – Reinier Melian Feb 16 '18 at 15:02
  • @ReinierMelian Tried that but still didn't fix my issue, so I started from fresh and did the proper constraints and now it's working (still have a different issue, but will open a new question for that), thanks for your trouble. – dylanvdb Feb 18 '18 at 21:15
  • @DylanvandenBrink which question is that? – Reinier Melian Feb 18 '18 at 21:27
  • @ReinierMelian just created it because I wanted to try and fix it myself, no luck so far; https://stackoverflow.com/questions/48863166/uistackview-within-uiscrollview-is-cut-off – dylanvdb Feb 19 '18 at 09:38

1 Answers1

1

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.

  • I will accept this as the answer because I think this is the most helpful for people visiting this question, thanks! – dylanvdb Feb 18 '18 at 21:15