두 섹션이있는 테이블을 만들었습니다. 두 번째 섹션이 아닌 첫 번째 섹션에 삭제 버튼을 표시 할 때 앱을 원합니다. 다음 코드를 작성했습니다.한 섹션에서 행을 삭제하는 방법
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
Book_own *temp= (Book_own *)[self.books objectAtIndex:indexPath.row];
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[books removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
}
하지만 편집 버튼을 누르면 두 섹션 모두에 삭제 버튼이 표시됩니다. 어떻게 방지하고 첫 번째 섹션에서 삭제합니까 ???
덕분에이 날 (didSelectRowAtIndexPath)을 수행 할 수 있습니까? –
에 대한 –
예 UITableViewCellEditingStyleNone에서만 재생합니다. 이 말은 편집 스타일 만 의미하지만 UITableViewSelectionStyleNone은 의미가 없습니다. 우리는 아무 것도 변경하지 않으며 doselectrowatindexpath를 실행하는 데 책임이 있습니다 –