[英]iOS Swift 3 - Autolayout, change height depends on text or view size
I have a view like below image: 我有一个如下图的视图:
This is a cell in uitableview I use uitextview with exclusion path to make the text flows around the right view (the view with image & text at the bottom). 这是uitableview中的一个单元格,我使用带有排除路径的uitextview来使文本围绕正确的视图(底部带有图像和文本的视图)流动。 Sometimes the text is short and the right view is longer, but sometimes otherwise.
有时文本简短而正确的视图较长,但有时则相反。 I'm not sure how to calculate the height of uitextview with exclusion path in order to compare with the right view and decide which height is used to set for the cell.
我不确定如何使用排除路径计算uitextview的高度,以便与正确的视图进行比较并确定用于单元格设置的高度。
My cell is setup like this: 我的单元格设置如下:
cell has 3 containers 牢房有3个容器
container 1 is header which is a label 容器1是标头,它是标签
container 2 is the image above which contains a text view and on the right is a custom view with photo & text below it 容器2是上面的图像,其中包含一个文本视图,右边是一个自定义视图,下面是照片和文本
container 3 can be images, text or empty 容器3可以是图片,文本或空白
How should I setup autolayout for this? 我应该如何为此设置自动布局? I'm using Swift 3 & autolayout
我正在使用Swift 3和自动布局
Provide the constraints to the text view in table view cell. 在表视图单元格中为文本视图提供约束。 And in viewDidLoad of your tableView controller set below properties:
并在tableView控制器的viewDidLoad中设置以下属性:
self.tableView.estimatedRowHeight = 44
self.tableView.allowsMultipleSelection = true
Refer this link: http://candycode.io/self-sizing-uitextview-in-a-uitableview-using-auto-layout-like-reminders-app/ 请参阅以下链接: http : //candycode.io/self-sizing-uitextview-in-a-uitableview-using-auto-layout-like-reminders-app/
Hope this would be helpful! 希望这会有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.