我的单元格包含单个图像视图,其中包含以下约束:
make_fav.js.erb
在viewDidLoad中,我设置了以下内容:
(function() {
var id = "#favourite-<%= @product.id %> i";
<% if current_user.products.exists?(product.id) %>
$(id).addClass('fa-star').removeClass('fa-star-o');
<% else %>
$(id).addClass('fa-star-o').removeClass('fa-star');
<% end %>
})();
但是,当表格加载时,该单元格高度约为40磅,并且在日志中显示:
left - 12
top - 12
right - 12
height - 300
在cellForRow ..我用url设置图像。
答案 0 :(得分:1)
你是否尝试过减少优先级约束?...给250以下的某个人...试试这个怎么办?
答案 1 :(得分:1)
在约束中,您还会添加底部约束,因为您已在此处发布约束。
答案 2 :(得分:1)
你也需要这个。
bottom - 12
答案 3 :(得分:1)
#0 0x00000001007f97a0 in specialized _assertionFailure(_:_:file:line:flags:) ()
#1 0x0000000100ec5a12 in specialized static _KVOKeyPathBridgeMachinery._bridgeKeyPath(_:) ()
#2 0x0000000100e32142 in NSSortDescriptor.init<A, B>(keyPath:ascending:) ()
不能是随机值。它必须是一个大约等于预期高度的值。在您的情况下,提到的值为estimatedRowHeight
,但80
的高度为imageView
。所以你得到的警告是价值不明确。
您将故事板中300
的高度更改为tableViewCell
并更新约束。仅设置尾部,前导,顶部和底部约束。如果正在使用图像的高度,则可以将值设置为80
。