Skip to content

Commit c896f55

Browse files
committed
Fixed #17: Crash when tapping a floating section header of the last section.
1 parent dda8488 commit c896f55

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

FZAccordionTableView/FZAccordionTableView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ - (NSInteger)sectionForHeaderView:(UITableViewHeaderFooterView *)headerView {
206206

207207
NSInteger section = NSNotFound;
208208
NSInteger minSection = 0;
209-
NSInteger maxSection = self.numberOfSections;
209+
NSInteger maxSection = self.numberOfSections-1;
210210

211211
CGRect headerViewFrame = headerView.frame;
212212
CGRect compareHeaderViewFrame;
@@ -220,10 +220,10 @@ - (NSInteger)sectionForHeaderView:(UITableViewHeaderFooterView *)headerView {
220220
}
221221
else if (headerViewFrame.origin.y > compareHeaderViewFrame.origin.y) {
222222
minSection = middleSection+1;
223+
section = middleSection; // Occurs when headerView sticks to the top
223224
}
224225
else {
225226
maxSection = middleSection-1;
226-
section = maxSection; // Occurs when headerView sticks to the top
227227
}
228228
}
229229

0 commit comments

Comments
 (0)