我将 subview 添加到 UITableViewCell
即
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault` reuseIdentifier:cellIdentifier];
这里_cellBackgroundView
属于UIView
。
[cell.contentView addSubview:_cellbackground];
我想通过 isDescendantOfView
的帮助检查它是否包含 _cellbackground
,但我收到了警告。
if (![_cellbackground isDescendantOfView:[cell subviews]]) {
[cell.contentView addSubview:_cellbackground];
}
else{
[_cellbackground removeFromSuperview];
}
引用 Check if a subview is in a view
请帮忙
[cell subviews]
返回数组,但是您需要将 UIView
作为 isDescendantOfView:
方法的输入参数,尝试这样它会工作
if (![_cellbackground isDescendantOfView:cell.contentView]) {
[cell.contentView addSubview:_cellbackground];
}
else {
[_cellbackground removeFromSuperview];
}
关于ios - 如何检查 UITableViewCell 是否包含 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37538974/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) | Powered by Discuz! X3.4 |