어떤 버튼을 눌렀는지에 따라 셀을 변경하는 tableview가 있습니다. 첫 번째 테이블보기에서 나는 단추를 눌렀을 때만 셀을 스 와이프 할 수 있기를 원합니다. 그렇지 않은 경우 스 와이프 기능을 사용 중지해야합니다. 버튼을 누르면 tableview가 스 와이프 가능하고 원하는 동작을 보여줍니다. 그러나 버튼을 누르지 않으면 셀은 여전히 "삭제"작업으로 스 와이프 가능합니다. 셀 레이블에 현재 사용자의 이름이 포함되어있는 경우 행을 스 와이프 할 수 없도록하고 싶지 않습니다.특정 셀에서만 허용 된 스 와이프
맨 아래 테이블 뷰에 대한 코드를 추가했습니다. 이 문제를 어떻게 해결할 수 있습니까? 1 테이블
코드 :
override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let cell = tableView.cellForRow(at: indexPath) as! DetailsCell
let detailsAction = UITableViewRowAction(style: UITableViewRowActionStyle.default, title: "Details") { (action , indexPath) -> Void in
if isCharacterButtonPressed == true { //if button is pressed
if cell.label != currentUser.name{
let viewController = self.storyboard?.instantiateViewController(withIdentifier: "SeeDetails") as! DetailsVC
viewController.person = cell.person
self.navigationController?.pushViewController(viewController, animated: true)
} else {
return .none
}
return [detailsAction] //makes cell swipe-able
} else { //if button is not pressed
return .none //do not make the cell swipe-able
}
}
편집 :
나는 canEditRow
기능을 고정했지만,이 빨간색 원을 강타 할 수있는 세포의 측면에 표시 때 그들을 문지르십시오. 이 문제를 어떻게 해결할 수 있습니까?