Skip to content

Commit

Permalink
fix bug: #29
Browse files Browse the repository at this point in the history
  • Loading branch information
TalkingJourney committed Oct 24, 2019
1 parent 4615a17 commit 65d05e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions SCIndexView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Pod::Spec.new do |s|

s.name = "SCIndexView"
s.version = "2.2.1"
s.version = "2.2.2"
s.summary = "SCIndexView provide a index view."
s.description = "SCIndexView provide a index view like Wechat. It is very easy."

Expand All @@ -20,7 +20,7 @@ Pod::Spec.new do |s|

s.platform = :ios, "7.0"

s.source = { :git => "https://github.com/TalkingJourney/SCIndexView.git", :tag => "2.2.1" }
s.source = { :git => "https://github.com/TalkingJourney/SCIndexView.git", :tag => "2.2.2" }

s.source_files = "SCIndexView/**/*.{h,m}"
s.public_header_files = "SCIndexView/**/*.h"
Expand Down
20 changes: 13 additions & 7 deletions SCIndexView/SCIndexView.m
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,11 @@ - (void)onActionWithDidSelect
} else {
NSInteger currentSection = self.currentSection + self.startSection;
if (currentSection >= 0 && currentSection < self.tableView.numberOfSections) {
CGRect rect = [self.tableView rectForSection:currentSection];
CGFloat offsetY = rect.origin.y - insetTop;
CGFloat offsetMaxY = self.tableView.contentSize.height + self.tableView.contentInset.bottom - self.tableView.bounds.size.height;
CGPoint contentOffset = self.tableView.contentOffset;
contentOffset.y = offsetY < offsetMaxY ? offsetY : offsetMaxY;
self.tableView.contentOffset = contentOffset;
NSUInteger rowCountInSection = [self.tableView numberOfRowsInSection:currentSection];
if (rowCountInSection > 0) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:currentSection];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
}
}
}

Expand Down Expand Up @@ -276,7 +275,14 @@ - (CAShapeLayer *)createSearchLayer

- (void)showIndicator:(BOOL)animated
{
if (self.currentSection < 0 || self.currentSection >= (NSInteger)self.subTextLayers.count) return;
if (self.currentSection >= (NSInteger)self.subTextLayers.count) return;

if (self.currentSection < 0) {
if (self.currentSection == SCIndexViewSearchSection) {
[self hideIndicator:animated];
}
return;
}

CATextLayer *textLayer = self.subTextLayers[self.currentSection];
if (self.configuration.indexViewStyle == SCIndexViewStyleDefault) {
Expand Down

0 comments on commit 65d05e6

Please sign in to comment.