diff --git a/GCRetractableSectionController/GCRetractableSectionController.h b/GCRetractableSectionController/GCRetractableSectionController.h index 276e83f..8510dbf 100644 --- a/GCRetractableSectionController/GCRetractableSectionController.h +++ b/GCRetractableSectionController/GCRetractableSectionController.h @@ -8,7 +8,9 @@ #import -@interface GCRetractableSectionController : NSObject +@interface GCRetractableSectionController : NSObject { + NSUInteger activeSection; +} @property (nonatomic, assign, getter = isOpen) BOOL open; @@ -38,6 +40,7 @@ - (void) didSelectCellAtRow:(NSUInteger) row; - (void) didSelectTitleCell; - (void) didSelectContentCellAtRow:(NSUInteger) row; +- (void) didSelectCellAtRow:(NSUInteger)row inSection:(NSUInteger)section; //Reserved for subclasses @property (nonatomic, readonly) UIViewController *viewController; diff --git a/GCRetractableSectionController/GCRetractableSectionController.m b/GCRetractableSectionController/GCRetractableSectionController.m index f10012f..9fab798 100644 --- a/GCRetractableSectionController/GCRetractableSectionController.m +++ b/GCRetractableSectionController/GCRetractableSectionController.m @@ -151,12 +151,20 @@ - (void) didSelectCellAtRow:(NSUInteger)row { else [self didSelectContentCellAtRow:row - 1]; } +- (void) didSelectCellAtRow:(NSUInteger)row inSection:(NSUInteger)section { + activeSection = section; + [self didSelectCellAtRow:row]; +} + - (void) didSelectTitleCell { self.open = !self.open; if (self.contentNumberOfRow != 0) [self setAccessoryViewOnCell:[self.tableView cellForRowAtIndexPath:[self.tableView indexPathForSelectedRow]]]; NSIndexPath* indexPath = [self.tableView indexPathForSelectedRow]; NSUInteger section = indexPath.section; + if (indexPath == nil) { + section = activeSection; + } NSUInteger contentCount = self.contentNumberOfRow; [self.tableView beginUpdates];