Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

响应didSelectRowAtIndexPath #46

Closed
CoderHua opened this issue May 5, 2016 · 9 comments
Closed

响应didSelectRowAtIndexPath #46

CoderHua opened this issue May 5, 2016 · 9 comments

Comments

@CoderHua
Copy link

CoderHua commented May 5, 2016

点击播放中的视频区域,会响应didSelectRowAtIndexPath.
怎么回事,是cell高度动态计算的原因吗?如果是请问我应该如何解决呢?
菜鸟一枚,真心请教!

@zhengwu119
Copy link

zhengwu119 commented Jun 27, 2016

确实是有这个问题,替代方案:

//UITableViewCell.m
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
NSLog(@"touch.view:%@",touch.view);
if ([touch.view isDescendantOfView:self.playerView]) {
self.touchedInPlayer = YES;
self.selectionStyle = UITableViewCellSelectionStyleNone;
return YES;
}
self.selectionStyle = UITableViewCellSelectionStyleDefault;
self.touchedInPlayer = NO;
return NO;
}

//UITableView
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.touchedInPlayer) return;

// bla bla bla...
}

@lihanst
Copy link

lihanst commented Jul 27, 2016

这是我的理解,可能有不对的地方:在playerView.m的createGesture方法里作者添加了单击和双击两个手势,并且使用了方法requireGestureRecognizerToFail,让单击手势在双击手势识别失败后才识别。这样的话当用户单击了cellPlayerView,手势识别器先捕捉到touch,然后发送hit-textview,两者各自做出响应,在单击识别器还在识别该touch时(在等待双击识别器识别),此touch已经传递到了cell上去了,cell识别了它,响应了didSelectRowAtIndexPath。如果将requireGestureRecognizerToFail去除,touch会立刻被单击识别器识别,触发单击事件,cell不会识别该touch, 但是当用户双击cellPlayerView时,则会同时响应单击双击事件,这是一个处理方式。第二个处理方式,增加一句代码tap. delaysTouchesBegan = true,这样的话,在单击识别器识别到一个touch时,并不会传递给hit-testView,cell没有touch到达,cell不会响应didSelectRowAtIndexPath,单双击手势也不会被同时识别,但是单击事件的识别会慢0.15ms。我选择第二个处理方式。参考:http://www.jianshu.com/p/2e074db792ba,http://www.codes51.com/article/detail_308743.html

@renzifeng
Copy link
Owner

thank you

@ctwlilei
Copy link

ctwlilei commented Aug 8, 2016

我现在就是和didselet冲突了。我的操作是push到新的页面。有无解决办法?

@lihanst
Copy link

lihanst commented Aug 8, 2016

上面两个comment你看了没?

@ctwlilei
Copy link

ctwlilei commented Aug 9, 2016

@lihanst @renzifeng 我是说作者不修改代码解决这个问题么? 如果我改了代码,将来怎么再更新呀

@renzifeng
Copy link
Owner

我前些天就修复了这个bug啦

@ctwlilei
Copy link

ctwlilei commented Aug 9, 2016

@renzifeng 我刚刚参考 @zhengwu119 的修改成功。不过我要改多处,现在才改好一处。看来我要回滚了。那你为何不关掉bug呀。
顺便问下,滑动cell然后视频收缩右下角有没有bool控制关掉这种特性。目前我们只想滑出屏幕关掉视频。

@ctwlilei
Copy link

ctwlilei commented Aug 9, 2016

@renzifeng 现在我更新到最新的pods 版 1.1.7 问题并没有解决。 然后下载了demo安装pod之后发现各种报错。根本运行不起来。
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants