나는 이것이 바보 같은 질문처럼 들리 겠지만, 나는 모든 곳을 보았다. 어떻게해야합니까?애니메이션이있는 UITableViewCell을 추가/삭제 하시겠습니까?
swype-to-delete 방법으로이 작업을 수행하는 방법을 알고 있지만이 기능을 사용하지 않는 이유는 무엇입니까?
일부 코드 샘플을 게시하십시오.
감사합니다.
Coulton
나는 이것이 바보 같은 질문처럼 들리 겠지만, 나는 모든 곳을 보았다. 어떻게해야합니까?애니메이션이있는 UITableViewCell을 추가/삭제 하시겠습니까?
swype-to-delete 방법으로이 작업을 수행하는 방법을 알고 있지만이 기능을 사용하지 않는 이유는 무엇입니까?
일부 코드 샘플을 게시하십시오.
감사합니다.
Coulton
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
insertIndexPaths
은 테이블에 삽입 할 NSIndexPaths의 배열입니다.
deleteIndexPaths
은 테이블에서 삭제할 NSIndexPaths의 배열입니다. 인덱스 경로에 대한
예 배열 형식 :
NSArray *insertIndexPaths = [[NSArray alloc] initWithObjects:
[NSIndexPath indexPathForRow:0 inSection:0],
[NSIndexPath indexPathForRow:1 inSection:0],
[NSIndexPath indexPathForRow:2 inSection:0],
nil];
insertRowsAtIndexPaths:withRowAnimation:
및 deleteSections:withRowAnimation:
두 가지 방법을 사용하려면 UITableView documentation에 모두 입력해야합니다.
감사합니다. 여기 내가하고있는 일이있다 :'\t \t \t [processList removeObjectAtIndex : 0]; \t \t \t [theTableView beginUpdates]; \t \t \t [theTableView deleteRowsAtIndexPaths : 0 withRowAnimation : UITableViewRowAnimationFade]; \t \t \t [theTableView deleteSections : 0 withRowAnimation : UITableViewRowAnimationFade]; \t \t \t [theTableView endUpdates]; 그러나 아무 반응이 없습니다. – iosfreak
tableView.beginUpdates()
tableView.deleteRowsAtIndexPaths([YourIndexPathYouWantToDeleteFrom], withRowAnimation: .Fade)
tableView.insertRowsAtIndexPaths([YourIndexPathYouWantToInsertTo], withRowAnimation: .Fade)
tableView.endUpdates()
스위프트 2.1
에서 그리고 당신과 같이 쉽게 NSIndexPath를 만들 수 있습니다 답장을NSIndexPath(forRow: 0, inSection: 0)
답변 해 주셔서 감사합니다! 당신의 방법을 다음과 같이 사용했습니다 :'\t \t NSArray * insertIndexPaths = [[NSArray alloc] initWithObjects : [NSIndexPath indexPathForRow : 0 inSection : 0], nil]; \t \t \t \t [theTableView beginUpdates]; \t \t [theTableView deleteRowsAtIndexPaths : insertIndexPaths withRowAnimation : UITableViewRowAnimationLeft]; \t \t [theTableView endUpdates]; '하지만 여전히 아무것도하지 못했습니다. 'theTableView' 부분과 관련이 있다고 생각합니다. 'self.tableView'를 시도 할 때 구조체 또는 합집합이 아니라고 알려줍니다 ... 감사합니다! – iosfreak
당신의 뷰 컨트롤러는 UITableViewController를 서브 클래스화할 필요가 있거나 UIViewController 일 경우 UITableViewDelegate와 UITableViewDataSource 프로토콜을 함축적으로 구현해야합니다. 그런 다음 인터페이스 빌더에서 뷰에 테이블 뷰를 추가하고 뷰 컨트롤러에 delegate 및 dataSource 속성을 연결합니다. – Sabobin
UITableViewDelegate 및 DataSource (내보기에서 내 UITableView에 연결되어 있습니다) UIViewController 같이 내 하위 클래스가 있습니다. 내가 뭘 잘못하고 있니? – iosfreak