我有一个UITableViewController,其中包含一些动态单元格和一个" Edit" -Button。 Cell如下所示:http://de.share-your-photo.com/95733637a1
如果我按下"编辑 - "按钮,则运行以下代码:
func editCells(_ sender:UIButton!){
self.isEditing = !self.isEditing
}
出现红色圆圈(左)和右边3个灰色条纹。但他们把我的洞穴弄得一团糟,看起来像这样:http://de.share-your-photo.com/a45ed5ff00
有没有办法识别此单元格是否处于编辑样式以隐藏某些标签或更改约束?
感谢您的期待!
答案 0 :(得分:0)
根据@ DekelMaman的评论,我能够解决自己的问题。谢谢你,非常棒的支持!对于每个对此感兴趣的人,这是我的解决方案:
class TasksTableViewCell: UITableViewCell {
@IBOutlet weak var DistanceLable: UILabel!
@IBOutlet weak var TimeLable: UILabel!
@IBOutlet weak var StretchingTimeLable: UILabel!
@IBOutlet weak var distanceDescriptionLeadingConstraint: NSLayoutConstraint!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
override func willTransition(to state: UITableViewCellStateMask) {
if(self.frame.width != 320.0) { return } //Continue only if its an iPhone 4, 5
print("State: \(state)")
if(state == .init(rawValue: 2147483649)){ //isEditing
self.distanceDescriptionLeadingConstraint.constant = -22
} else { //isNormal
self.distanceDescriptionLeadingConstraint.constant = 16
}
}
}
答案 1 :(得分:0)