Reputation: 1305
I have a problem with my iOS Application. I'm using Swift and XCode 6.3. I have a UITableViewController in my application and in this TableView I've created a prototype cell (Custom). In the design it looks like this:
This is how I want the cells (left the title and on the right a switch in every cell).
But my problem is, if I run the project it looks like this on my iPhone:
What do I have to do that the cell is looking like my prototype cell? Thank you in advance!
Upvotes: 1
Views: 152
Reputation: 9975
Your title label is probably overlapping the switch view. You need to set an auto-layout constraint of horizontal spacing
between the right edge (trailing in auto layout language...) of the label and the left edge (leading) of the switch view.
1. ctrl+drag from the label to the switch:
2. pick horizontal spacing:
relation
to be Greater than or equal
instead equal
, and set the constant
to whatever minimum distance you want to have between the label and the switch: EDIT:
To get the label without having to subclass UITableViewCell
you can set a tag to the label:
Then inside cellForRow..
you can get it with myCell.viewWithTag(999)
Upvotes: 3