英文:
UITableViewCell renders wrongly
问题
My UITableViewCell lines are not working properly. If the label has a long text the wrapping of the text is not made as planned and the cell constraints are also not laying out the cell as should. Line randomly look like these:
First 3 lines are ok, next two is laid out bad. text should wrap inside.
What is causing this?
The label is constraint on the front and end. The end is constraint to the switch with a larger or equal to 10. Switch is constraint to the right edge. Left and Right constraints are with priority 1000, label to switch with 750.
英文:
My UITableViewCell lines are not working properly. If the label has a long text the wrapping of the text is not made as planned and the cell constraints are also not laying out the cell as should. Line randomly look like these:
First 3 lines are ok, next two is laid out bad. text should wrap inside.
What is causing this?
The label is constraint on the front and end. The end is constraint to the switch with a larger or equal to 10. Switch is constraint to the right edge. Left and Right constraints are with priority 1000, label to switch with 750.
答案1
得分: 1
你不应该需要更改任何优先级,并且不需要设置开关的宽度...
这是单元格的原型 --
- 标签(黄色背景以便我们看到它的框架)
- 顶部/前导/底部约束到内容视图边距
- 行数:0
- 开关
- 顶部/尾部约束到内容视图边距
- 前导约束到标签尾部
>= 10
在Storyboard中看起来像这样:
在运行时看起来像这样:
所有约束的优先级都保持默认值。
英文:
You shouldn't need to change any priorities, and you do not need to set the width of the switch...
Here is the cell prototype --
- label (yellow background so we can see its frame)
- constrained Top / Leading / Bottom to content view margins
- number of lines: 0
- switch
- constrained Top / Trailing to content view margins
- Leading to label Trailing
>= 10
Looks like this in Storyboard:
and looks like this when running:
All constraint priorities are at their defaults.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论