swift - 如何删除以编程方式添加的约束

标签 swift constraints

如何以编程方式删除此约束。请帮忙

cell.textView.addConstraint(NSLayoutConstraint(item: cell.textView, attribute: .height, relatedBy: .greaterThanOrEqual,
                                                           toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: 54))

该代码已添加到表格单元格中。我想在键盘隐藏时删除。

最佳答案

var constraint = NSLayoutConstraint(item: cell.textView, attribute: .height, relatedBy: .greaterThanOrEqual,
                                                           toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: 54)

constraint.isActive = false

关于swift - 如何删除以编程方式添加的约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54942366/

相关文章:

ios - 在视频帧下添加ScrollView

asp.net-mvc - boolean 的MVC路线约束

iOS:自动布局导致 UIScrollView 不滚动

java - 约束解决推断类型以重构 Java 代码

swift - 为 UIKitForMac 构建 iPad 应用时出现构建错误

swift - ModelIO 框架不工作

swift - 如何在 PFTablequery 中返回多个 findObjectsInBackground

swift - "Variadic enum cases are not supported"swift 5 错误

ios - objective-C : animating height constraint change not working

android - 可以依赖 SQLiteConstraint 并让 SQLite 为我进行检查吗?有陷阱吗?