diff --git a/example/UIBubbleTableViewExample/ViewController.m b/example/UIBubbleTableViewExample/ViewController.m index e0b49ae..14933c1 100644 --- a/example/UIBubbleTableViewExample/ViewController.m +++ b/example/UIBubbleTableViewExample/ViewController.m @@ -56,4 +56,13 @@ - (NSBubbleData *)bubbleTableView:(UIBubbleTableView *)tableView dataForRow:(NSI return [bubbleData objectAtIndex:row]; } +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + return YES; +} + +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + [bubbleData removeObjectAtIndex:indexPath.row]; + [tableView reloadData]; +} + @end diff --git a/src/UIBubbleTableView.m b/src/UIBubbleTableView.m old mode 100644 new mode 100755 index 4b794dc..d9dd641 --- a/src/UIBubbleTableView.m +++ b/src/UIBubbleTableView.m @@ -203,4 +203,18 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N return cell; } +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + if ([self.bubbleDataSource respondsToSelector:@selector(tableView:canEditRowAtIndexPath:)]) { + return [self.bubbleDataSource tableView:tableView canEditRowAtIndexPath:indexPath]; + } + + return NO; +} + +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if ([self.bubbleDataSource respondsToSelector:@selector(tableView:commitEditingStyle:forRowAtIndexPath:)]) { + [self.bubbleDataSource tableView:tableView commitEditingStyle:editingStyle forRowAtIndexPath:indexPath]; + } +} + @end diff --git a/src/UIBubbleTableViewDataSource.h b/src/UIBubbleTableViewDataSource.h old mode 100644 new mode 100755 index e5fc192..18d331f --- a/src/UIBubbleTableViewDataSource.h +++ b/src/UIBubbleTableViewDataSource.h @@ -19,6 +19,9 @@ @optional +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath; +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath; + @required - (NSInteger)rowsForBubbleTable:(UIBubbleTableView *)tableView;