I am trying to create a custom subclass of UITableViewCell
that displays an image and a few labels to the right of the image. I have my UIImageView
and UILabels
arranged in stack views, the outermost of which I pinned to all four sides of the content view.
But when I run the app in the simulator, I do not see the image views. Debugging the view hierarchy, I see they are getting clipped.
And digging in a little further by focusing on the outermost stack view with "Show Constraints" on, I don't see my auto layout constraints at all (instead I get an ambiguous position runtime warning for each of the outermost stack views).
向右展开的文本标签设置为0行,表格视图得到一个常量estimatedRowHeight
价值及其rowHeight
set to UITableViewAutomaticDimension
,所以我认为如果这些约束起作用,表中的行的大小将适合内容。也许值得注意的是,当我调试视图层次结构时,我添加的任何宽度或高度自动布局约束都会出现,所以我知道运行时存在一些约束,我只是无法弄清楚为什么相对于内容视图的约束是不是。
经过很长时间的努力,并让一位更有经验的开发人员检查我的项目后,似乎它的设置方式没有任何问题。使用完全相同的布局和约束从头开始重新创建表视图单元格并使用完全相同的代码解决了此问题。在这种情况发生之前,我已经对堆栈视图和约束进行了相当多的修改,因此当您在模拟器中运行应用程序时,Xcode 可能无法正确设置约束。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)