iOS 类似美团外送食品app两个tableView联合浮动作效果果落到实处

//// LeftTableView.m// TwoTableViewConnected//// Created by KevinHe on
2017/12/21.// Copyright © 2017年 KevinHehuachao. All rights
reserved.//#import “LeftTableView.h”@interface LeftTableView
()@property (nonatomic,assign)NSInteger currentSelectedIndex;

1在storyboard中放好五个tableView的布局

写在头里

写在眼下

第一声明哈,不是广告,小编不怕用的时候以为那个作用相比较风趣,就想着实现了一晃。效果如图:

图片 1PageBlurTestGif.gif

接下去大约的说一下思路吧~

多年来完毕了下饿了么中选餐时两级tableView联动作效果果,先上效果图,大家感受一下:

@end

图片 2

先是注解哈,不是广告,小编固然用的时候感觉这一个职能相比较有趣,就想着实现了瞬间。效果如图:

大致思路

兴许咱们看看这种成效的落到实处的时候,首先想着的是本人在这些调控器中左右各放贰个tableView,然后进行关联。小编是用了另一个思路,具体如下:小编建了七个类LGJCategoryVC用来绽放左侧写着第几类的tableView和LGJProductsVC用来盛开右侧写在种种成品的tableView。然后将LGJProductsVC作为LGJCategoryVC的childViewController,将LGJProductsVCviewaddSubView到LGJCategoryVCview上。代码实现如下:

- createProductsVC { _productsVC = [[LGJProductsVC alloc] init]; _productsVC.delegate = self; [self addChildViewController:_productsVC]; [self.view addSubview:_productsVC.view];}

如此那般做有哪些收益吗?一言以蔽之正是将tableView告别,各自行使二个congtroller,这样做使每一个调整器管理自身的tableView里面包车型大巴事件,可以更加好的握别代码,裁减多少个tableView时期的耦合度,相同的时候也防止了把八个
tableView放在四个controller里形成叁个controller代码的冗余,那样使逻辑更清晰。

收纳来说一下大家点击侧面tableViewcell的时候如何使右侧的tableView随着滑动。作者在LGJCategoryVC也便是侧面tableView的那么些代理方法中didSelectRowAtIndexPath做了些操作:

- tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (_productsVC) { [_productsVC scrollToSelectedIndexPath:indexPath]; }}

在那之中这几个scrollToSelectedIndexPath办法是在_productsVC中声明的。这几个方式就是有血有肉调节左侧tableView滑动的。

#pragma mark - 一级tableView滚动时 实现当前类tableView的联动- scrollToSelectedIndexPath:(NSIndexPath *)indexPath { [self.productsTableView selectRowAtIndexPath:([NSIndexPath indexPathForRow:0 inSection:indexPath.row]) animated:YES scrollPosition:UITableViewScrollPositionTop];}

小编们供给的只是让侧边tableViewsectionHeaderView随行左边包车型的士点击cell一抬手一动脚到顶上部分就足以了,所以在此地大家设置selectRowAtIndexPath:([NSIndexPath indexPathForRow:0 inSection:indexPath.row])

接下去正是当大家滑动左边tableView的时候右边手的tableViewcell紧跟着滑动。这里我们在LGJProductsVC类中宣称了二个体协会谈商讨。

@protocol ProductsDelegate <NSObject>- willDisplayHeaderView:(NSInteger)section;- didEndDisplayingHeaderView:(NSInteger)section;@end

同有的时候间评释多少个变量,这八个变量特别有效。

@property(nonatomic, assign)BOOL isScrollUp;//是否是向上滚动@property(nonatomic, assign)CGFloat lastOffsetY;//滚动即将结束时scrollView的偏移量

现实成效就在此地了:

#pragma mark - scrollViewDelegate- scrollViewDidScroll:(UIScrollView *)scrollView { NSLog(@"_lastOffsetY : %f,scrollView.contentOffset.y : %f", _lastOffsetY, scrollView.contentOffset.y); _isScrollUp = _lastOffsetY < scrollView.contentOffset.y; _lastOffsetY = scrollView.contentOffset.y; NSLog(@"______lastOffsetY: %f", _lastOffsetY);}

在那么些方法中,_isScrollUp用来剖断左边的tableView是还是不是是向上海好笑剧团,当scrollView滑动时,我们用上次的偏移量和本次的偏移量作对照,倘若上次的偏移量小于此番的偏移量表明tableView是前进滑动的。(关于contentOffset小编在上篇的《iOS
落成NavigationController的titleView动态缩放效果》链接:
中有大约介绍)此时,_isScrollUp为YES,反之为NO。大家依照_isScrollUp这几个入眼的标志来到此时:UITableViewDelegate的这七个代理方法

- tableView:(UITableView *)tableView willDisplayHeaderView:view forSection:(NSInteger)section { if (self.delegate != nil && [self.delegate respondsToSelector:@selector(willDisplayHeaderView:)] != _isScrollUp) { [self.delegate willDisplayHeaderView:section]; } }- tableView:(UITableView *)tableView didEndDisplayingHeaderView:view forSection:(NSInteger)section { if (self.delegate != nil && [self.delegate respondsToSelector:@selector(didEndDisplayingHeaderView:)] && _isScrollUp) { [self.delegate didEndDisplayingHeaderView:section]; }}

UITableViewDelegate的那八个代理方法中,第一个点子是当headerView就要展现时调用。第四个措施是当headerView终结呈现时调用。在这里我们依据_isScrollUp的BOOL值,当headerView快要彰显的时候证实此时_isScrollUp为NO,因为那时候是向下滑动的。当headerView终结彰显的时候证实此时_isScrollUp为YES,因为那时是发展滑动的。此时大家调用ProductsDelegate代理方法,在LGJCategoryVC类中贯彻代理方法:

#pragma mark - ProductsDelegate- willDisplayHeaderView:(NSInteger)section { [self.categoryTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:section inSection:0] animated:YES scrollPosition:UITableViewScrollPositionMiddle];}- didEndDisplayingHeaderView:(NSInteger)section { [self.categoryTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:section + 1 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionMiddle];}

willDisplayHeaderView本条代理方法中,右侧tableView向下滑动,此时headerView将在展现,侧边cell选择indexPathForRow:section,在didEndDisplayingHeaderView代理方法中,右侧tableView开采进取滑动,此时headerView竣事展现,侧边cell选择indexPathForRow:section+1

图片 3联合浮动功能

@implementation LeftTableView

2 代码部分

图片 4

总结

主旨的大概思路就是地点那几个,或然老是左边手tableView右边tableView的看起来有个别绕了,具体的要么看代码吧。最后贴上代码链接:

下边说下实际落到实处步骤:先是解释一下,落成那几个要求重视是两点,一是点击侧边tableView,同一时候滚动侧边tableView到具体的职责。二是拖动侧边tableView选中上手tableView对应的某一行。要完成这一个供给有少数很要紧:侧边的tableView每一行对应的是左边手tableView的各种分区,OK,Just
Do It.

– (instancetype)init

#import “TwoTablesViewController.h”

接下去大致的说一下思路吧~

兑现点击侧边tableView同一时候滚动右侧tableView,很简短,只需求完结tableView的代办方法- tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;然后在代理方法里边得到右侧的tableView,实现让其滚动到第indexPath.row分区,第0行就可以,代码如下:

{

@interface TwoTablesViewController ()

大致思路

- tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ // 如果点击的是右边的tableView,不做任何处理 if (tableView == self.rightTableView) return; // 点击左边的tableView,设置选中右边的tableView某一行。左边的tableView的每一行对应右边tableView的每个分区 [self.rightTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:indexPath.row] animated:YES scrollPosition:UITableViewScrollPositionTop];}

self = [super init];

@property (weak, nonatomic) IBOutlet UITableView *leftTableView;

唯恐大家来看这种作用的兑现的时候,首先想着的是本身在那几个调整器中左右各放多少个tableView,然后开展关联。我是用了另二个思路,具体如下:

咱俩那边不管理左侧tableView的点击事件,所以if (tableView == self.rightTableView) return;

if {

@property (weak, nonatomic) IBOutlet UITableView *rightTableView;

自个儿建了三个类LGJCategoryVC用来盛开左侧写着第几类的tableView和LGJProductsVC用来盛放侧面写在各样产品的tableView。然后将LGJProductsVC作为LGJCategoryVC的childViewController,将LGJProductsVC的viewaddSubView到LGJCategoryVC的view上。

接下去大家落成拖动左侧tableView选中左侧tableView对应的某一行,大家要动态选中侧边包车型客车tableView,就必要得到最近滚动到了要命分区,UITableView有四个代理方法,- tableView:(UITableView *)tableView willDisplayHeaderView:view forSection:(NSInteger)section // 一个头标题即将显示的时候掉用- tableView:(UITableView *)tableView didEndDisplayingHeaderView:view forSection:(NSInteger)section // 一个头标题即将消失的时候掉用选拔那多个法子就能够得到目前所在分区达成这一个成效了。

[self createUI];

@end

代码达成如下:

然而作者总感觉那一个点子不佳,还会有个更简单的秘技,其实tableView有个极偶然用,但很牛X的章程,叫做index帕特hsForVisibleRows,官方文书档案解释是:

[self initData];

@implementation TwoTablesViewController {

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”>- style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>void style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,45,122)!important”>createProductsVC style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>{

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_productsVC style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>
= style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[[ style=””>LGJProductsVC style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=””>alloc style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>] style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
init style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>];

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_productsVC style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>delegate style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>
= self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>;

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=””>self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
addChildViewController style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_productsVC style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>];

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=””>self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>view style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
addSubview style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_productsVC style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>view style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>];

style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>}

The value of this property is an array of NSIndexPath objects each
representing a row index and section index that together identify a
visible row in the table view. If no rows are visible, the value is
nil.

}

NSArray *_leftArray;

如此做有啥好处呢?简单的讲正是将tableView分离,各自行使一个congtroller,那样做使各样调控器管理本人的tableView里面包车型的士平地风波,能够越来越好的告别代码,缩短七个tableView之间的耦合度,同期也防止了把三个tableView放在一个controller里造成一个controller代码的冗余,这样使逻辑更显著。

简易意思正是,它回到贰个装着脚下显示器上可知的cell的indexPath集结。

return self;

NSArray *_rightArray;

接收来讲一下大家点击侧边tableView的cell的时候什么使右侧的tableView跟着滑动。小编在LGJCategoryVC也正是左边tableView的那个代理方法中didSelectRowAtIndexPath做了些操作:

好的,珍视来了,获得那个集结,不就能够获得如今显示器上最上部的cell的indexpath了呢,那就安枕无忧的获得未来所在第indexpath.section个分区了。

}

}

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”>- style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>void style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:teal!important”>tableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>UITableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=””>* style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,45,122)!important”>tableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:teal!important”>
didSelectRowAtIndexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>NSIndexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=””>* style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,45,122)!important”>indexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>{

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=””>if style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_productsVC style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>{

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>         style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important”>_productsVC style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
scrollToSelectedIndexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:indexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>];

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>}

style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>}

说了如此多,上代码:

– initData{

– (void)viewDidLoad {

个中那些scrollToSelectedIndexPath方法是在_productsVC中宣示的。那个方法正是具体调度左边tableView滑动的。

 #pragma mark - UIScrollViewDelegate-scrollViewDidScroll:(UIScrollView *)scrollView{ // 监听tableView滑动 // 如果现在滑动的是左边的tableView,不做任何处理 if ((UITableView *)scrollView == self.leftTableView) return; // 滚动右边tableView,设置选中左边的tableView某一行。indexPathsForVisibleRows属性返回屏幕上可见的cell的indexPath数组,利用这个属性就可以找到目前所在的分区 [self.leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:self.rightTableView.indexPathsForVisibleRows.firstObject.section inSection:0] animated:YES scrollPosition:UITableViewScrollPositionMiddle];}

self.currentSelectedIndex = 0;

[super viewDidLoad];

style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(184,92,0)!important”>#pragma
mark – 一流tableView滚动时 完结当前类tableView的联合浮动

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>- style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>void style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>scrollToSelectedIndexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>NSIndexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=””>* style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>indexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>{

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=””>self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>productsTableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
selectRowAtIndexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>([ style=””>NSIndexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
indexPathForRow style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,153,153)!important”>0 style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
inSection style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:indexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>row style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>]) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
animated style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:YES style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
scrollPosition style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:UITableViewScrollPositionTop style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>];

style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>}

多少解释一下,首先监听scrollView的拖动,本demo不管理右边tableView的轮转,所以if ((UITableView *)scrollView == self.leftTableView) return;``self.rightTableView.indexPathsForVisibleRows.firstObject.section那句是获得当下荧屏上可知cell的率先行cell所在的分区,然后让左侧的tableView选中第0分区的这一行就OK了。

}

_leftArray = [[NSArray alloc]
initWithObjects:@”第一类”,@”第二类”,@”第三类”,@”第四类”,@”第五类”,@”第六类”,@”第七类”,@”第八类”,
nil];

大家必要的只是让左侧tableView的sectionHeaderView跟随左边包车型客车点击cell移动到最上端就能够了,所以在那边大家设置selectRowAtIndexPath:([NSIndexPath
indexPathForRow:0 inSection:indexPath.row])

款待收藏本小说,最终附上demo ,Github传送门:demo

– refreshData:dataArray{

_rightArray = [[NSArray alloc]
initWithObjects:@”一”,@”二”,@”三”,@”四”,@”五”,@”六”, nil];

接下去正是当大家滑动左边tableView的时候左手的tableView的cell跟随滑动。这里我们在LGJProductsVC类中声称了多个体协会谈商讨。

--------------那叫分水线---------------补充下:下面切磋提到说点击左边tableView的时候会有黑影效果,其实是这么的,点击左边的tableView,左侧的tableView是从当前地方动画滚动到对应岗位的,既然有滚动,就能够调- scrollViewDidScroll:(UIScrollView *)scrollView那几个代理方法,说白了就是拖动了侧面tableView,拖动左侧的过程中会陆续选中左侧。那本身想大家就知道了。

[self.dataSource removeAllObjects];

[_leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0
inSection:0] animated:YES
scrollPosition:UITableViewScrollPositionNone];

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=””>@protocol style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=””>ProductsDelegate style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(102,102,102)!important”><NSObject>

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>- style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>void style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>willDisplayHeaderView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>NSInteger style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>section style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>;

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>- style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>void style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>didEndDisplayingHeaderView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>NSInteger style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>section style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>;

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

@end

假设不想要这些成效,有三个法子,一个是一贯吧- tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath中的动画滚动的属性animated值改成NO

[self.tableView reloadData];

}

并且评释多少个变量,那七个变量非常管用。

- tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ // 如果点击的是右边的tableView,不做任何处理 if (tableView == self.rightTableView) return; // 点击左边的tableView,设置选中右边的tableView某一行。左边的tableView的每一行对应右边tableView的每个分区 [self.rightTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:indexPath.row] animated:NO scrollPosition:UITableViewScrollPositionTop];}

[self setSeletedIndex:self.currentSelectedIndex];

– (void)didReceiveMemoryWarning {

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=””>@property style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(128,0,128)!important”>nonatomic style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>, style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(128,0,128)!important”>assign style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=””>BOOL style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,45,122)!important”>isScrollUp style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>; style=””>//是不是是向上滚动

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=””>@property style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(128,0,128)!important”>nonatomic style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>, style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(128,0,128)!important”>assign style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=””>CGFloat style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>lastOffsetY style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>; style=””>//滚动将要结束时scrollView的偏移量

如此做侧面的tableView就是无动画滚动了,也就不会再调scrollViewDidScroll:方法。可是就算还想左侧tableViewyou滚动效应,另一种缓和情势是:把- scrollViewDidScroll:(UIScrollView *)scrollView办法换到- scrollViewDidEndDecelerating:(UIScrollView *)scrollView这么些代理方法格局就行了。饿了么有的分界面类似便是如此做的,可是有bug(猜测饿了么没测出来),那几个格局的笺注为

}

[super didReceiveMemoryWarning];

现实职能就在此地了:

// called when scroll view grinds to a halt
当滚动视图半上落下--有道翻译如是说

– createUI{

// Dispose of any resources that can be recreated.

style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(184,92,0)!important”>#pragma
mark – scrollViewDelegate

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>- style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>void style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>scrollViewDidScroll style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>UIScrollView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=””>* style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>scrollView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>{

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=””>NSLog style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(221,17,68)!important”>@”_lastOffsetY
: %f,scrollView.contentOffset.y : %f” style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>, style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_lastOffsetY style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>, style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>scrollView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>contentOffset style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>y style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>);

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_isScrollUp style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>
= style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_lastOffsetY style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>
< style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>scrollView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>contentOffset style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>y style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>;

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_lastOffsetY style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>
= style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>scrollView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>contentOffset style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>y style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>;

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=””>NSLog style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(221,17,68)!important”>@”______lastOffsetY:
%f” style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>, style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_lastOffsetY style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>);

style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>}

依赖我亲测,拖拽之后,那么些办法调用与否在于你的指头是不是在动画停止此前离开了荧屏,要是在动画结束在此之前手指离开显示屏,此办法调用没什么难点。but,假若动画已经终止,再把手指拿开,这几个方式是不会调的。有图有真相:

UITableView *tableView = [[UITableView
alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH*3/10.0,
SCREEN_HEIGHT-64) style:UITableViewStyleGrouped];

}

在这些点子中,_isScrollUp用来推断左边的tableView是或不是是向上海滑稽剧团,当scrollView滑动时,我们用上次的偏移量和此番的偏移量作对照,假诺上次的偏移量小于此次的偏移量表明tableView是进化滑动的。(关于contentOffset小编在上篇的《iOS
完成NavigationController的titleView动态缩放效果》链接:
中有简介)此时,_isScrollUp为YES,反之为NO。大家遵照_isScrollUp这一个关键的标志来到此时:UITableViewDelegate的那七个代理方法

图片 5WZBLinkageTableViewGif.gif

tableView.dataSource = self;

-(NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section {

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”>- style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>void style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:teal!important”>tableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>UITableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=””>* style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,45,122)!important”>tableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:teal!important”>
willDisplayHeaderView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>UIView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=””>* style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,45,122)!important”>view style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:teal!important”>
forSection style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>NSInteger style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,45,122)!important”>section style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; line-height:inherit!important; color:rgb(51,51,51)!important”>{

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=””>if style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>delegate style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>
!= nil style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>
&& style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=””>self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>delegate style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
respondsToSelector style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=””>@selector style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>willDisplayHeaderView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>)] style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>
!= style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_isScrollUp style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>{

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>         style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=””>self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>delegate style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
willDisplayHeaderView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:section style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>];

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>}

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>}

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>- style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>void style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>tableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>UITableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=””>* style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>tableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
didEndDisplayingHeaderView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>UIView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=””>* style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>view style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
forSection style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>NSInteger style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>section style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>{

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=””>if style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>delegate style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>
!= nil style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>
&& style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=””>self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>delegate style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
respondsToSelector style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=””>@selector style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>didEndDisplayingHeaderView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>)] style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>
&& style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>_isScrollUp style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>{

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>         style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=””>self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>delegate style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
didEndDisplayingHeaderView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:section style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>];

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>}

style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>}

缓和这么些bug的关键在于,让手指离开的时候手动调一遍这么些代理方法,那怎么技巧领略手指何时离开呢?scrollView给大家了另多少个代理方法:- scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:velocity targetContentOffset:(inout CGPoint *)targetContentOffset其一办法在得了拖拽的时候调,正好化解了笔者们的难题:

tableView.delegate = self;

if (tableView == _rightTableView) {

在UITableViewDelegate的那八个代理方法中,第二个方法是当headerView将在突显时调用。第4个法子是当headerView结束展现时调用。在此地大家依照_isScrollUp的BOOL值,当headerView将在显示的时候证实此时_isScrollUp为NO,因为那时是向下滑动的。当headerView截止展现的时候证实此时_isScrollUp为YES,因为这时候是前进滑动的。此时大家调用ProductsDelegate代理方法,在LGJCategoryVC类中落到实处代理方法:

- scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:velocity targetContentOffset:(inout CGPoint *)targetContentOffset{ // 推拽将要结束的时候手动调一下这个方法 [self scrollViewDidEndDecelerating:scrollView];}

tableView.showsVerticalScrollIndicator = NO;

return [_leftArray objectAtIndex:section];

style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(184,92,0)!important”>#pragma
mark – ProductsDelegate

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>- style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>void style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>willDisplayHeaderView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>NSInteger style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>section style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>{

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=””>self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>categoryTableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
selectRowAtIndexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=””>NSIndexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
indexPathForRow style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:section style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
inSection style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,153,153)!important”>0 style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>] style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
animated style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:YES style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
scrollPosition style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:UITableViewScrollPositionMiddle style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>];

style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>}

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>- style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>void style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>didEndDisplayingHeaderView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>( style=””>NSInteger style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>) style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>section style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>{

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> 

style=”margin:0px; padding:0px; max-width:100%!important; word-wrap:break-word!important; font-size:12px”> style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>     style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=””>self style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>. style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>categoryTableView style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
selectRowAtIndexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>[ style=””>NSIndexPath style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
indexPathForRow style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:section style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>

  • style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,153,153)!important”>1 style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
    inSection style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,111,224)!important”>: style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,153,153)!important”>0 style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>] style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
    animated style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:YES style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:teal!important”>
    scrollPosition style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(0,45,122)!important”>:UITableViewScrollPositionMiddle style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>];

    style=”margin:0px; padding:0px; border:0px; font-family:inherit; height:inherit; max-width:100%!important; word-wrap:break-word!important; font-size:inherit!important; line-height:inherit!important; color:rgb(51,51,51)!important”>}

OK,解决难题!后续,github也会跟进的,多谢大家的欢腾和支撑!

tableView.bounces = NO;

}

在willDisplayHeaderView那一个代理方法中,左边tableView向下滑动,此时headerView就要展现,右边cell采取indexPathForRow:section,在didEndDisplayingHeaderView代理方法中,侧边tableView向上海滑稽剧团动,此时headerView截至展现,左侧cell选拔indexPathForRow:section+1

Github已经更新,最新demo在那 demo

[tableView registerClass:[UITableViewCell class]
forCellReuseIdentifier:@”LeftTableViewUITableViewCell”];

return nil;

总结

你还足以参与大家的群,大家开庭日期待你的参预!

tableView.tableHeaderView = [[UIView alloc]
initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH*3/10.0, CGFLOAT_MIN)];

}

中央的概略思路正是下边这一个,恐怕老是侧边tableView右侧tableView的看起来某些绕了,具体的要么看代码吧。最终贴上代码链接:

图片 6咱俩的社区

self.tableView = tableView;

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

[self addSubview:self.tableView];

if (tableView == _rightTableView) {

但愿得以和豪门一块儿交换,一齐提高。

self.backgroundColor = [UIColor colorWithRed:250/255.0 green:250/255.0
blue:250/255.0 alpha:1];

return [_leftArray count];

self.tableView.backgroundColor = [UIColor colorWithRed:250/255.0
green:250/255.0 blue:250/255.0 alpha:1];

}

}

return 1;

– setSeletedIndex:(NSInteger)index{

}

if (self.currentSelectedIndex == index) {

-(NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {

return;

if (tableView == self.leftTableView) {

}

return _leftArray.count;

self.currentSelectedIndex = index;

}

[self.tableView reloadData];

else if (tableView == self.rightTableView) {

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index
inSection:0];

return _rightArray.count;

if (self.dataSource.count>index) {

}

[self.tableView selectRowAtIndexPath:indexPath animated:NO
scrollPosition:UITableViewScrollPositionMiddle];

return 1;

}

}

}

-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {

– (NSInteger)currentSeletedIndex{

//    UITableViewCell *cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];

return self.tableView.indexPathForSelectedRow.row;

if (tableView == self.leftTableView) {

}

UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@”leftCell”];

#pragma mark – tableView.dataSource

cell.textLabel.text = [_leftArray objectAtIndex:indexPath.row];

– (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section{

return cell;

return 10;

}

}

else  {

– (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath{

UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@”rightCell”];

UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@”LeftTableViewUITableViewCell”];

cell.textLabel.text = [_rightArray objectAtIndex:indexPath.row];;

if (self.currentSelectedIndex == indexPath.row) {

return cell;

cell.backgroundColor = [UIColor whiteColor];

}

}

}

else{

-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

cell.backgroundColor = [UIColor colorWithRed:250/255.0 green:250/255.0
blue:250/255.0 alpha:1];

if (tableView == _leftTableView) {

}

//        [_rightTableView scrollToRowAtIndexPath:[NSIndexPath
indexPathForRow:0 inSection:indexPath.row]
atScrollPosition:UITableViewScrollPositionTop animated:YES];

cell.textLabel.text = [NSString
stringWithFormat:@”%ld”,indexPath.row];

[_rightTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0
inSection:indexPath.row] animated:YES
scrollPosition:UITableViewScrollPositionTop];

return cell;

}

}

else {

#pragma mark – delegate.tableview

[_leftTableView selectRowAtIndexPath:[NSIndexPath
indexPathForRow:indexPath.section inSection:0] animated:NO
scrollPosition:UITableViewScrollPositionTop];

– tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

}

self.currentSelectedIndex = indexPath.row;

}

[self.tableView reloadData];

-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView
willDecelerate:(BOOL)decelerate {

UITableViewCell *cell = [self.tableView
cellForRowAtIndexPath:indexPath];

NSLog(@”33333333″);

[self setCellSelected:cell];

if (scrollView == _rightTableView) {

NSIndexPath *indexPathTemp = [NSIndexPath indexPathForRow:0
inSection:indexPath.row];

NSIndexPath *indexPath = [[_rightTableView indexPathsForVisibleRows
] objectAtIndex:0];

if ([self.delegate
respondsToSelector:@selector(setCurrentIndexPath:)]) {

[_leftTableView selectRowAtIndexPath:[NSIndexPath
indexPathForRow:indexPath.section inSection:0] animated:NO
scrollPosition:UITableViewScrollPositionNone];

[self.delegate setCurrentIndexPath:indexPathTemp];

}

}

}

}

//滑动截至时实行

– setCellSelected:(UITableViewCell *)cell{

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {

if {

NSLog(@”33333333″);

cell.backgroundColor = [UIColor whiteColor];

if (scrollView == _rightTableView) {

}

NSIndexPath *indexPath = [[_rightTableView indexPathsForVisibleRows
] objectAtIndex:0];

}

[_leftTableView selectRowAtIndexPath:[NSIndexPath
indexPathForRow:indexPath.section inSection:0] animated:NO
scrollPosition:UITableViewScrollPositionNone];

//// ViewController.m// TwoTableViewConnected//// Created by KevinHe on
2017/12/21.// Copyright © 2017年 KevinHehuachao. All rights
reserved.//#import “ViewController.h”#import
“LeftTableView.h”@interface ViewController ()@property
(nonatomic,weak)UITableView *tableView;

}

@property (nonatomic,strong)NSMutableArray *dataSource;

}

@property (nonatomic,weak)LeftTableView *leftTableView;

@end

@property (nonatomic,assign)BOOL leftTableViewNeedScroll;

3 运转作效果果

@end

图片 7

@implementation ViewController

– viewDidLoad {

[super viewDidLoad];

[self createUI];

[self initData];

}

– initData{

//注意 要开头化

self.leftTableViewNeedScroll = YES;

}

– createUI{

//右侧视图

LeftTableView *leftTableView = [[LeftTableView alloc]init];

[self.view addSubview:leftTableView];

_leftTableView = leftTableView;

_leftTableView.frame = CGRectMake(0, 64, SCREEN_WIDTH*3/10,
SCREEN_HEIGHT-64);

self.leftTableView.delegate = self;

self.leftTableView.backgroundColor = [UIColor colorWithRed:250/255.0
green:250/255.0 blue:250/255.0 alpha:1];

//tableView

UITableView *tableView = [[UITableView
alloc]initWithFrame:CGRectMake(SCREEN_WIDTH*3/10.0, 64,
SCREEN_WIDTH*7/10.0, SCREEN_HEIGHT-64) style:UITableViewStylePlain];

tableView.dataSource = self;

tableView.delegate = self;

tableView.showsVerticalScrollIndicator = NO;

tableView.bounces = NO;

[tableView registerClass:[UITableViewCell class]
forCellReuseIdentifier:@”UITableViewCell”];

tableView.backgroundColor = [UIColor grayColor];

self.tableView = tableView;

[self.view addSubview:self.tableView];

//ios 11 以上的主题材料

self.tableView.estimatedRowHeight = 0;

self.tableView.estimatedSectionHeaderHeight = 0;

self.tableView.estimatedSectionFooterHeight = 0;

}

#pragma mark – scrollView.delegate

– scrollViewDidScroll:(UIScrollView *)scrollView{

[self getCurrentSection];

}

– scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView{

self.leftTableViewNeedScroll = YES;

}

//调度左侧的tableview

– getCurrentSection{

NSArray *array = [self.tableView visibleCells];

if (array.count) {

UITableViewCell *cell = [array objectAtIndex:0];

NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];

if (indexPath) {

if ([self.leftTableView currentSeletedIndex]!=indexPath.section

&& self.leftTableViewNeedScroll) {

[self.leftTableView setSeletedIndex:indexPath.section];

}

}

}

}

#pragma mark – delegate.LeftTableView

– setCurrentIndexPath:(NSIndexPath*)indexPath{

self.leftTableViewNeedScroll = NO;

NSArray *array = [self.tableView visibleCells];

if (array.count) {

UITableViewCell *cell = [array objectAtIndex:0];

NSIndexPath *indexPathTemp = [self.tableView indexPathForCell:cell];

if (indexPath) {

if (indexPathTemp.section!=indexPath.section) {

[self.tableView selectRowAtIndexPath:indexPath animated:YES
scrollPosition:UITableViewScrollPositionTop];

}

}

}

}

#pragma mark – tableView.delegate

– (nullable UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section{

UILabel *label = [[UILabel alloc]init];

label.frame = CGRectMake(0, 0, SCREEN_WIDTH, 36);

label.text = [NSString stringWithFormat:@”%ld”,section];

return label;

}

– tableView:(UITableView*)tableView
heightForHeaderInSection:(NSInteger)section{

return 36;

}

#pragma mark – tableView.dataSource

– (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

return 10;

}

– (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section{

return 10;

}

– (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath{

UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@”UITableViewCell”];

cell.textLabel.text = [NSString stringWithFormat:@”section=%ld
row=%ld”,indexPath.section,indexPath.row];

return cell;

}

#pragma mark – 点击事件

– tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

}

发表评论

电子邮件地址不会被公开。 必填项已用*标注