http://ios.jobbole.com/92573/ 这个是百度到的
http://www.jianshu.com/p/630b644bf430这个是根据Api百度下的
写得很不错,找了好久才找到的,百度给的资源很少,希望对大家有用.
这个是单个点击的响应
if (clickBtn.tag!=1) {
UIImpactFeedbackGenerator *generator = [[UIImpactFeedbackGenerator alloc] initWithStyle: UIImpactFeedbackStyleLight];
[generator prepare];
[generator impactOccurred];
NSIndexPath * indexPath = [NSIndexPath indexPathForRow:0 inSection:clickBtn.tag-1];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
NSString * charStr = self.allIndexes[clickBtn.tag-1];
[self showIndexTipLabel:charStr];
}else{
UIImpactFeedbackGenerator *generator = [[UIImpactFeedbackGenerator alloc] initWithStyle: UIImpactFeedbackStyleLight];
[generator prepare];
[generator impactOccurred];
[self.tableView scrollRectToVisible:_searchBar.frame animated:NO];
}
这个是滑动的响应
CGPoint point = [pan translationInView:self.sidetableView];
CGFloat orgin_y = point.y;
NSInteger location = orgin_y/20;
float locationF = orgin_y/20;
if (location>0&&location<self.allIndexes.count) {
NSIndexPath * indexPath = [NSIndexPath indexPathForRow:0 inSection:location];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
NSString * charStr = self.allIndexes[location];
[self showIndexTipLabel:charStr];
UISelectionFeedbackGenerator *generator = [[UISelectionFeedbackGenerator alloc] init];
switch (pan.state) {
case UIGestureRecognizerStateBegan:
{
[generator prepare];
}
break;
case UIGestureRecognizerStateChanged:
{
if ((locationF-location)<0.1) {
[generator selectionChanged];
[generator prepare];
}
}
break;
case UIGestureRecognizerStateCancelled:
case UIGestureRecognizerStateEnded:
case UIGestureRecognizerStateFailed:
{
generator = nil;
}
break;
default:
break;
}