ios tableview嵌套套tableView 支持左右滑动 上下联动

给TableView添加手势冲突解决方案
UIPanGestureRecognizer&*panGesture =
(UIPanGestureRecognizer*)gestureR
pan.delegate&= (id&&/span&UIGestureRecognizerDelegate&)self;
(BOOL)gestureRecognizer:(UIGestureRecognizer&*)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer&*)otherGestureRecognizer
& &&if&([otherGestureRecognizer.view
isKindOfClass:[UITableView class]]) {
&&return&YES;
&&return&NO;
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。嵌套的tableview丝滑的滚动实现 - CSDN博客
嵌套的tableview丝滑的滚动实现
在iOS遇到嵌套的滚动总是不可避免的,但是如何才能做到两个滚动控件无缝的丝滑的滚动呢?&
博主最开始考虑的是控制手势优先级来实现,但是尝试过的朋友朋友应该知道,效果一般,不能做到丝滑的交替滑动。后面博主想到了另一种实现方式效果还不错,分享给大家。核心是把最外层的滚动控件设置可以同时响应多个手势。把项目抽出一个demo给大家参考,是一个经典的滑动嵌套交互Demo。
本文已收录于以下专栏:
相关文章推荐
http://blog.csdn.net/lizhongfu2013/article/details/
问题由来:项目需要做类似网易新闻的那种UIScrollView上放多个...
UITableView和UIScrollView共存,滚动条滚动问题。UIScrollView中放了一个UITableView,两个滚动条会冲突,wo'd
IOS开发~UISCrollView与UITableView嵌套使用终极解决方案 
问题由来:项目需要做类似网易新闻的那种UIScrollView上放多个UITableView的效果,其中UITa...
一、案例演示IOS中提供的UITableView功能非常强大,section提供分组,cell提供显示,几乎可以应付绝大部分场景。最近想模仿旧版的淘宝的商品详情页(最新的淘宝详情页商品详情和图文详情是...
在开发iOS的过程当中,我们经常需要模拟不同的网络环境,来对程序进行测试。以下是分别对模拟器和真机状态下的两种不同的方法,亲测有效。
1.模拟器情况下
模拟器方面,苹果给我们提供了一个很实用的工具...
1、cell中嵌套Tableview
笔者尝试画了一张图,尽量反映出实现的思路:
外层UITableView通过HYBMasonryAutoCellHeight计算cell...
他的最新文章
讲师:宋宝华
讲师:何宇健
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)iOS 两个tableView联动效果的实现 - 简书
iOS 两个tableView联动效果的实现
1在storyboard中放好两个tableView的布局
2 代码部分#import "TwoTablesViewController.h"@interface TwoTablesViewController ()@property (weak, nonatomic) IBOutlet UITableView *leftTableV@property (weak, nonatomic) IBOutlet UITableView *rightTableV@end@implementation TwoTablesViewController {NSArray *_leftANSArray *_rightA}- (void)viewDidLoad {[super viewDidLoad];_leftArray = [[NSArray alloc] initWithObjects:@"第一类",@"第二类",@"第三类",@"第四类",@"第五类",@"第六类",@"第七类",@"第八类", nil];_rightArray = [[NSArray alloc] initWithObjects:@"一",@"二",@"三",@"四",@"五",@"六", nil];[_leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionNone];}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.}-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {if (tableView == _rightTableView) {return [_leftArray objectAtIndex:section];}}-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {if (tableView == _rightTableView) {return [_leftArray count];}return 1;}-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {if (tableView == self.leftTableView) {return _leftArray.}else if (tableView == self.rightTableView) {return _rightArray.}return 1;}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {//
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];if (tableView == self.leftTableView) {UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"leftCell"];cell.textLabel.text = [_leftArray objectAtIndex:indexPath.row];}else
{UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"rightCell"];cell.textLabel.text = [_rightArray objectAtIndex:indexPath.row];;}}-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {if (tableView == _leftTableView) {//
[_rightTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:indexPath.row] atScrollPosition:UITableViewScrollPositionTop animated:YES];[_rightTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:indexPath.row] animated:YES scrollPosition:UITableViewScrollPositionTop];}else {[_leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.section inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];}}-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {NSLog(@"");if (scrollView == _rightTableView) {NSIndexPath *indexPath = [[_rightTableView indexPathsForVisibleRows ] objectAtIndex:0];[_leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.section inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];}}//滑动停止时执行-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {NSLog(@"");if (scrollView == _rightTableView) {NSIndexPath *indexPath = [[_rightTableView indexPathsForVisibleRows ] objectAtIndex:0];[_leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.section inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];}}@end3 运行效果ios实现两个tableview联动_iostableview上下联动_词汇网
ios实现两个tableview联动
责任编辑:词汇网 发表时间: 16:01:34
两个tableview的联动,滑动左侧tableview,右侧tableview跟着滑动其实实现起来比较简单,只是需要搞清楚他们之间的区别和联系,还有就是调用一个- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section这个方法,从而实现左右两个tableview的联动直接上代码@implementation ViewController{ UITableView *_rightTableV UITableView *_leftTableV NSArray *_leftTableS NSArray *_rightTableS }初始化数据源- (void)viewDidLoad { [superviewDidLoad]; // Do any additional setup after loading the view, typically from a nib. _leftTableSource [@"11",@"22",@"33",@"44",@"55",@"66"]; _rightTableSource [@{@"header":@"11",@"title":@[@"aa",@"bb",@"cc",@"dd",@"ee",@"ff"]}, @{@"header":@"22",@"title":@[@"gg",@"mm",@"nn",@"oo",@"pp",@"qq"]}, @{@"header":@"33",@"title":@[@"rr",@"ss",@"jj",@"xx",@"yy",@"zz"]}, @{@"header":@"44",@"title":@[@"aa",@"bb",@"cc",@"dd",@"ee",@"ff"]}, @{@"header":@"55",@"title":@[@"gg",@"mm",@"nn",@"oo",@"pp",@"qq"]}, @{@"header":@"66",@"title":@[@"rr",@"ss",@"jj",@"xx",@"yy",@"zz"]}];
[selfsetupSomeParamars];}创建两个tableview- (void)setupSomeParamars{ _rightTableView = [[UITableViewalloc] initWithFrame:CGRectMake(100,0, self.view.frame.size.width - 100, self.view.frame.size.height)style:UITableViewStyleGrouped]; _rightTableView.dataSource = _rightTableView.delegate = [self.viewaddSubview:_rightTableView];
_leftTableView = [[UITableViewalloc] initWithFrame:CGRectMake(0,0, 100,self.view.frame.size.height)style:UITableViewStyleGrouped]; _leftTableView.dataSource = _leftTableView.delegate = [self.viewaddSubview:_leftTableView]; }设置cell的显示- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *reuseIdentifer "cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifer]; if(!cell){ cell = [[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:reuseIdentifer]; } if(tableView == _rightTableView){ cell.textLabel.text = [_rightTableSource[indexPath.section]objectForKey:@"title"][indexPath.row]; }elseif (tableView == _leftTableView){ cell.textLabel.text =_leftTableSource[indexPath.row]; } }- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ if (tableView == _rightTableView) { return 50; }else{ return 50; }}- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ if (tableView == _rightTableView) { return_rightTableSource. }else{ return 1; }}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (tableView == _leftTableView) { return_leftTableSource. }else{ return [[_rightTableSource[section]objectForKey:@"title"]count]; }}- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ if (tableView == _rightTableView) { return [_rightTableSource[section]objectForKey:@"header"]; }else{ }}- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ if(tableView == _rightTableView){ UILabel *label = [[UILabelalloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width-100,40)]; label.backgroundColor = [UIColorcyanColor]; label.text = [_rightTableSource[section]objectForKey:@"header"]; label.textColor = [UIColorredColor]; }else{ }}联动效果在于这里- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{ if(tableView == _rightTableView){ [_leftTableViewselectRowAtIndexPath:[NSIndexPathindexPathForItem:section inSection:0]animated:YESscrollPosition:UITableViewScrollPositionNone]; }}详情见demo,不过有些不足,望大牛们多多指点
上一集:没有了 下一集:
相关文章:&&&&&&&&
最新添加资讯
24小时热门资讯
附近好友搜索

我要回帖

更多关于 table里面嵌套table 的文章

 

随机推荐