Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use source indices for separators callbacks

  • Loading branch information...
commit 1634d6707d96a3267be1446c350adfd61e07575c 1 parent 0d7c0ad
Dmitry Stadnik authored
Showing with 14 additions and 15 deletions.
  1. +14 −15 BASeparatedTableProvider.m
View
29 BASeparatedTableProvider.m
@@ -65,11 +65,11 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+ NSIndexPath *sourceIndexPath = [NSIndexPath indexPathForRow:(indexPath.row / 3) inSection:indexPath.section];
switch (indexPath.row % 3) {
- case 0: return [self.delegate tableView:tableView topSeparatorCellForRowAtIndexPath:indexPath];
- case 1: return [self.delegate tableView:tableView
- cellForRowAtIndexPath:[NSIndexPath indexPathForRow:(indexPath.row / 3) inSection:indexPath.section]];
- case 2: return [self.delegate tableView:tableView bottomSeparatorCellForRowAtIndexPath:indexPath];
+ case 0: return [self.delegate tableView:tableView topSeparatorCellForRowAtIndexPath:sourceIndexPath];
+ case 1: return [self.delegate tableView:tableView cellForRowAtIndexPath:sourceIndexPath];
+ case 2: return [self.delegate tableView:tableView bottomSeparatorCellForRowAtIndexPath:sourceIndexPath];
}
return nil;
}
@@ -97,8 +97,8 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
if ((indexPath.row % 3 == 1) && [self.delegate respondsToSelector:@selector(tableView:canEditRowAtIndexPath:)]) {
- return [self.delegate tableView:tableView
- canEditRowAtIndexPath:[NSIndexPath indexPathForRow:(indexPath.row / 3) inSection:indexPath.section]];
+ NSIndexPath *sourceIndexPath = [NSIndexPath indexPathForRow:(indexPath.row / 3) inSection:indexPath.section];
+ return [self.delegate tableView:tableView canEditRowAtIndexPath:sourceIndexPath];
}
return NO;
}
@@ -114,9 +114,8 @@ - (void)tableView:(UITableView *)tableView
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ((indexPath.row % 3 == 1) && [self.delegate respondsToSelector:@selector(tableView:commitEditingStyle:forRowAtIndexPath:)]) {
- [self.delegate tableView:tableView
- commitEditingStyle:editingStyle
- forRowAtIndexPath:[NSIndexPath indexPathForRow:(indexPath.row / 3) inSection:indexPath.section]];
+ NSIndexPath *sourceIndexPath = [NSIndexPath indexPathForRow:(indexPath.row / 3) inSection:indexPath.section];
+ [self.delegate tableView:tableView commitEditingStyle:editingStyle forRowAtIndexPath:sourceIndexPath];
}
}
@@ -129,24 +128,24 @@ - (void)tableView:(UITableView *)tableView
//- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+ NSIndexPath *sourceIndexPath = [NSIndexPath indexPathForRow:(indexPath.row / 3) inSection:indexPath.section];
switch (indexPath.row % 3) {
case 0: {
- BACellSeparatorPositions positions = [self.delegate tableView:tableView separatorPositionsForRow:indexPath];
+ const BACellSeparatorPositions positions = [self.delegate tableView:tableView separatorPositionsForRow:sourceIndexPath];
if (positions & BACellSeparatorPositionTop) {
- return [self.delegate tableView:tableView heightForTopSeparatorRowAtIndexPath:indexPath];
+ return [self.delegate tableView:tableView heightForTopSeparatorRowAtIndexPath:sourceIndexPath];
}
return 0;
}
case 1:
if ([self.delegate respondsToSelector:@selector(tableView:heightForRowAtIndexPath:)]) {
- return [self.delegate tableView:tableView
- heightForRowAtIndexPath:[NSIndexPath indexPathForRow:(indexPath.row / 3) inSection:indexPath.section]];
+ return [self.delegate tableView:tableView heightForRowAtIndexPath:sourceIndexPath];
}
return 0;
case 2: {
- BACellSeparatorPositions positions = [self.delegate tableView:tableView separatorPositionsForRow:indexPath];
+ const BACellSeparatorPositions positions = [self.delegate tableView:tableView separatorPositionsForRow:sourceIndexPath];
if (positions & BACellSeparatorPositionBottom) {
- return [self.delegate tableView:tableView heightForBottomSeparatorRowAtIndexPath:indexPath];
+ return [self.delegate tableView:tableView heightForBottomSeparatorRowAtIndexPath:sourceIndexPath];
}
return 0;
}
Please sign in to comment.
Something went wrong with that request. Please try again.