iOS:自定义表格视图单元中的约束

骑自行车更好

我有一个带有自定义单元格的tableview,在其中有一个textview。对于此单元格,我用文本大小确定其高度,这没关系。

我在自动布局中工作,因此对于我的单元格,我使用两个约束以这种方式扩展所有空间单元格的textview

在此处输入图片说明

我可以说它可以正常工作,并且我的textview可以针对所有单元格空间进行扩展。

在视图控制器中,我有一个控件来检查文本(字符串)何时为空。当它为空时,我为单元格hight返回0。

但是在这种情况下,当我返回0且text_view为空时,我崩溃了,但是我不知道如何解决。

这是消息

Unable to simultaneously satisfy constraints.

Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x1704864a0 V:|-(25)-[UITextView:0x15454d960]   (Names: '|':UITableViewCellContentView:0x178179680 )>",
    "<NSLayoutConstraint:0x1704864f0 V:[UITextView:0x15454d960]-(23)-|   (Names: '|':UITableViewCellContentView:0x178179680 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x17889a220 h=--& v=--& V:[UITableViewCellContentView:0x178179680(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1704864f0 V:[UITextView:0x15454d960]-(23)-|   (Names: '|':UITableViewCellContentView:0x178179680 )>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
Akhilrajtr

设置TranslatesAutoresizingMaskIntoConstraintsNO单元格contentView的依据,

[self.contentView setTranslatesAutoresizingMaskIntoConstraints:NO];

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在自定义表格视图单元格中创建自定义视图?

iOS表格视图具有自定义子视图的单元格自动高度

分隔符未正确显示为ios中的自定义表格视图单元格

表格视图单元格之间的自定义视图

iOS-如何实现自定义表格视图单元格的选择/取消选择?

iOS 7自定义单元格未在表格视图中显示

尾部截断在自定义Xamarin.iOS表格视图单元上不起作用

自定义UITableViewCell中的视图约束因单元重用而重置

自定义表格视图单元格中UILabel中的行数

自定义表格视图单元格图像失真

使用UIView的自定义表格视图单元格

以编程方式设计自定义表格视图单元

如何在表格视图单元格中隐藏自定义类标签?

在自定义表格视图单元格中本地化按钮和标签[swift]

具有自定义表格视图单元的tableview在滚动中消失

无法在UI表格视图自定义单元格中创建分隔符插入

Swift中的自定义表格视图单元格,没有Storyboard

自定义表格视图单元格在xcode 6中快速

在情节提要中自定义表格视图单元时出现NSInternalInconsistencyException异常

故事板中的自定义表格视图单元格布局似乎无效

如何在表格中显示自定义页脚视图?

Google图表:表格中列的自定义视图

对自定义视图使用约束布局

TableView 自定义单元格中的自定义 UIView 在表格加载时“跳跃”

如何为自定义表视图单元动态设置约束?

iOS:在自定义视图中添加新约束取决于视图的框架

自定义视图不遵守约束布局中的约束

自定义Xib在表格视图中的动态单元格大小

Swift-带按钮的自定义表格视图单元格