테이블 뷰의 셀을 스 와이프 할 때 Github MGSwipeTableCell
(https://github.com/MortimerGoro/MGSwipeTableCell)의 오픈 소스 라이브러리를 사용하여 버튼을 나타냅니다.NSITableViewCell 삭제시 NSException
스 와이프하여 공개 된 버튼을 탭하면 충돌이 발생합니다.
// This is in the library delegate method:
// func swipeTableCell(_ cell: MGSwipeTableCell, swipeButtonsFor direction: MGSwipeDirection, swipeSettings: MGSwipeSettings, expansionSettings: MGSwipeExpansionSettings) -> [UIView]?
// local variables: buttons, one of which is:
let rejectFriendReqButton = MGSwipeButton(title: "", icon: UIImage(named: "X"), backgroundColor: RED) { (cell) -> Bool in
DispatchQueue.main.async(execute: {
self.friendListTableView.deleteRows(at: [self.friendListTableView.indexPath(for: cell)!], with: .fade)
})
return FriendingCloudKitUtils.declineFriendRequest()
}
// In an if-else ladder:
else if direction == MGSwipeDirection.rightToLeft { // reject friend request
if section == 2 { // friend requests
if direction == MGSwipeDirection.leftToRight { // accept friend request
return [acceptFriendReqButton]
}
else if direction == MGSwipeDirection.rightToLeft { // reject friend request
return [rejectFriendReqButton]
}
}
else if self.friendListTableView.indexPath(for: cell)?.section == 4 { // in friend section
return [unfriendButton]
}
}
충돌 내가 deleteRows
전화 라인에서 발생 : 여기 버튼을 눌러 때 호출되어야 폐쇄를 정의합니다. NSException
이 있습니다. 내가 lldb에 po $arg1
을 실행하면, 내가 얻을 : 나는 더 가능한 솔루션을 시도했습니다
error: Couldn't materialize: couldn't read the value of register x0
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
그들이 전역 변수 대신 로컬 하나로 버튼을 저장하는 중 나는, 추적 할 수있는 것보다.
기타 잠재적으로 관련 참고 사항 :
내가 디버그 모드로 전환, 테이블이 실제로 존재 :
<UITableView: 0x10186c000; frame = (0 0; 375 554); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x17425a760>; layer = <CALayer: 0x174236760>; contentOffset: {0, 0}; contentSize: {375, 357.5}>
도 풀어되고있는 indexPath
은 전무하지 않고 올바른 섹션을 가지고 있으며, 행 번호 :
lldb) po self.friendListTableView.indexPath(for: cell)!
▿ 2 elements
- 0 : 2
- 1 : 0
모든이 NSException
의 원인이 무엇에 대한 아이디어와 어떻게 고칠 수 있을까요? 애니메이션에있는 tableView로부터 행을 삭제, 수정 데이터 소스를 제하고 deleteRows
를 호출하기 위해
저는이 라이브러리에 필요하지 않다고 생각합니다. 이 데모에서는 일반적인 테이블 뷰 대리자 메서드를 사용하지 않습니다. https://github.com/MortimerGoro/MGSwipeTableCell/blob/master/demo/MailAppDemoSwift/MailAppDemoSwift/MailViewController.swift – mlecoz