UiTableView에 대한 작업을 삭제하기 위해 스 와이프를 구현하고 있습니다. 제대로 작동하는 테이블을 만들었습니다. 그러나 테이블보기에서 항목을 클릭하면 didSelectRowAt
이 호출되지 않습니다. 로그를 인쇄하지 않습니다.UiTableView didSelectRowAt 메서드가 호출되지 않았습니다.
코드 것은
class ManageUsersTable: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var editView: UIView!
@IBOutlet weak var main_user_table: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
editView.isHidden = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 6
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = Bundle.main.loadNibNamed("UsersTableCell", owner: self, options: nil)?.first as! UsersTableCell
cell.selectionStyle = UITableViewCellSelectionStyle.none
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("selected : \(indexPath.row)")
}
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
print("Delete at index : \(indexPath.row)")
let delete = UITableViewRowAction(style: .destructive, title: "Delete") { (action, indexPath) in
// delete item at indexPath
print("Delete at index : \(indexPath.row)")
self.editView.isHidden = false
}
// let edir = UITableViewRowAction(style: .normal, title: "Edit", icon : UIImage()) { (action, indexPath) in
// print("Edit at index : \(indexPath.row)")
// }
// edit.backgroundColor = UIColor.darkGray
// return [delete, edit]
return [delete]
}
}
어떤 사람이 날이 TNX를 해결하는 데 도움이 될 수 있습니다.
갱신
내가 왼쪽에서 오른쪽으로 스 와이프하면 방법은 작동합니다. 항목이 아님
당신은 그것의 스토리 보드/펜촉에 ManageUsersTable에있는 tableview 대리자를 설정해야? –
예. 델리게이트를 설정했습니다 –
'userInteractionEnabled' 속성을 한 번 확인하십시오. – Buntylm