自定义TableViewCell中的自动布局被忽略 [英] Autolayout is ignored in custom TableViewCell

查看:167
本文介绍了自定义TableViewCell中的自动布局被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试限制我的tableview单元格中的某些对象,以便将它们正确格式化并且不会在其他设备上剪辑.但是,每当我向其中的对象添加约束时,它将对象从屏幕抛到左上方.在所附的屏幕截图中,我用左侧的绿色条显示了它,但是当我对其他标签和文本字段进行操作时也是如此.

I'm trying to constrain some objects in my tableview cell so that they will be formatted correctly and won't clip on different devices. But, whenever I add a constraint to an object in there, it throws the object off screen to the top left. In the screenshot I attached I showed it with the green bar on the left but the same is true when I do it to the other labels and text fields.

关于我在做什么错的任何想法吗?

Any ideas as to what I'm doing wrong?

  • 我有一个几乎相同的表格视图,该表格视图是从另一个来源获取数据并以相同的方式进行约束,但是在构建表格时,该表格单元格的格式正确.

  • I have a near identical table view that gets its data from another source and have them constrained the same way, but that tableview cell is formatted correctly when I build it.

我正在网上看到有关Tableview单元子类的信息.为了使这些保持不变,我还应该执行其他操作吗?我不确定为什么它们要在我的一个表视图上工作,而不能在另一个表上工作.

I am seeing things online about Tableview cell subclasses. Is there something else I am supposed to be implementing in order to get these to stay? I'm not sure why they are working on one of my tableviews but not the other.

我遇到的问题与此处相同自定义UITableViewCell中的自动版式被忽略,但她的回答使我感到困惑,我不知道该如何重制它

I am having the same issue that is being seen here Autolayout is ignored in Custom UITableViewCell but her answer is confusing me and I can't figure out how to reproduce it

这是构建应用程序时的外观:

推荐答案

弄清楚了.对于将来可能会遇到此问题的其他任何人.您需要在情节提要中单击内容视图,然后转到赔偿检查器.然后从那里确保将Class设置为UIView的默认值,而不是TableView Cell的自定义类.

Figured it out. For anyone else who may have this problem in the future. You need to click on the content view in the Storyboard and go to the indemnity inspector. Then from there make sure the Class is set to the default of UIView and not the custom class of the TableView Cell.

这篇关于自定义TableViewCell中的自动布局被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆