From 94994ca1c0e5b94e5bb71d2e942136a77e022e9a Mon Sep 17 00:00:00 2001 From: iosdeveloper Date: Thu, 16 Aug 2012 17:34:09 +0200 Subject: [PATCH] Deleting table rows --- example/UIBubbleTableViewExample/ViewController.m | 9 +++++++++ src/UIBubbleTableView.m | 14 ++++++++++++++ src/UIBubbleTableViewDataSource.h | 3 +++ 3 files changed, 26 insertions(+) mode change 100644 => 100755 src/UIBubbleTableView.m mode change 100644 => 100755 src/UIBubbleTableViewDataSource.h 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;