首页 > 其他 > 详细

tableViewCell上的图片点击,cell变灰,点击其它cell跳转的indexPath不对

时间:2015-02-10 18:37:26      阅读:590      评论:0      收藏:0      [点我收藏+]

在tableViewCell上有一张可以点击的图片,通过Target-Action给图片的imageView添加了点击事件.

但是,在点击图片实现放大效果的时候,图片的背景cell变灰,再次点击其它cell进行页面跳转时,协议方法中得indexPath是刚才点击图片的背景cell的indexPath,不是当前点击的

 

开始是在图片点击事件中 增加了让选中的cell失去选中状态,但是背景cell只是变灰了,没有选中的cell,所以这个方法不好用.

后来 在自定义的cell中增加了touchesBegan的重写,代码如下

 1 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
 2     UITouch * touch = [touches anyObject];
 3     //方法1
 4 //    CGPoint point = [touch locationInView:self];
 5 //    if ([[self hitTest:point withEvent:event] isEqual:self.contentView]) {
 6 //        //点击到自己了
 7 //        [super touchesBegan:touches withEvent:event];
 8 ////        NSLog(@"1.dianziji == %@.",self);
 9 ////        NSLog(@"2.nextResponder == %@",self.nextResponder);
10 //    } else {
11 //        //没点击自己
12 ////        NSLog(@"3.dianziji == %@.",self);
13 ////        NSLog(@"4.nextResponder == %@",self.nextResponder);
14 //    }
15     
16     //方法2
17     UIView *view = [touch view];
18     if ([view isEqual:self.contentView]) {
19         [super touchesBegan:touches withEvent:event];
20     }
21 }
22 
23 @end

 

 

tableViewCell上的图片点击,cell变灰,点击其它cell跳转的indexPath不对

原文:http://www.cnblogs.com/lxllanou/p/4284414.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!