IOS UITableView cell suitable for screen width

I am new to iOS and am trying to use TableView for the first time.

I added a cell prototype to the TableView. It has a shortcut inside, which is on the right. When I run it on a lower display such as 4S, the label is not visible.

I tried setting Horizontal Space - Content View for the label (on the right side), but has no effect.

I once played with auto-layout, but can't figure out if anyone could be helpful to help me?

Edit:

enter image description here

+6
source share
4 answers

Before answering directly, I would say that I adhere to the self-timer and do not look at frames, springs and structures.

Now print UILabel. Select UILabel. Go to editor> display leading and upper space for viewing. Also attach the width and height (correct them if you want). Your problem has been resolved.

Go through this autorun book and keep playing. Auto Layout iOS Demystified, 2nd Edition

Updated after editing the question:

For a set of Label1:

  • Mark the leading, upper and lower viewing space.
  • Enter height (not width)

For a set of Label1:

  • Pin Trailing, upper and lower viewing space.
  • Return the height (not the width) again.

Now select both marks and go to the horizontal distance between them. And if while you are updating the frame ... also fulfill the restriction on updating.

+2
source

The restriction is not enough to determine the position of the vertical mark.

Two additional ways:

  • Add a Vertical Center in container constraint
  • Add a tag height limit and top distance to limit the limit ( contentView for the UITableViewCell your case)

With each of the above and existing limitations, the position of the UILabel can be precisely determined.

+1
source

provide vertical restrictions for your shortcut, if there is no need for automatic disconnection, you can disable autorun.

+1
source

On the shortcut, you can add restrictions on the leading, final, upper and high-altitude.

0
source

Source: https://habr.com/ru/post/988974/


All Articles