我在UITableViewCell
中有2个UITextField。调用setEditing
时,我还要更改borderStyle并启用TextFields。
进入编辑模式时,在动画过程中,UITextField
中的文本会跳到左侧,然后再移回到右侧。退出编辑模式后,它会跳到UILabel
旁边的UITextField
上方。
这是单元格setEditing
的内容:
super.setEditing(editing, animated: animated)
self.name.isEnabled = editing
self.value.isEnabled = editing
if !editing {
self.name.borderStyle = .none
self.value.borderStyle = .none
}
else {
self.name.borderStyle = .roundedRect
self.value.borderStyle = .roundedRect
}
这是editActionsForRowAt
:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let delete = UITableViewRowAction(style: .destructive, title: "Delete") { (action, indexPath) in
_ = self.list.removeItem(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .fade)
}
return [delete]
}
即使我删除了动画,这些字段也发生了奇怪的事情。
Here是活动单元的视频
编辑:这似乎是UITextField
中的文本右对齐的副作用。