2015-09-12 53 views
0

我在创建的所有单元格顶部都有黑色视图,当用户点击特定单元格时,其alpha将转至0.0f。无法选择正确单元格的正确内容

我一直在努力的是单元重用标识符,因此当我改变某个单元格的某些内容时,其他单元格的内容也会被编辑,因为它们共享相同的indexPath。

如何访问某个特定单元格的内容?

这是我在做什么 -

UITapGestureRecognizer *videoGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(moveVideoPlayer:)]; 
[self.optionView addGestureRecognizer:videoGesture]; 



-(void)moveVideoPlayer:(UITapGestureRecognizer *)tap { 

    CGRect visibleRect = (CGRect){.origin = self.tableView.contentOffset, .size = self.view.bounds.size}; 
    CGPoint visiblePoint = CGPointMake(CGRectGetMidX(visibleRect), CGRectGetMidY(visibleRect)); 
    NSIndexPath *visibleIndexPath = [self.tableView indexPathForRowAtPoint:visiblePoint]; 

    self.visibleIndex = (int)visibleIndexPath.row; 

    SearchCell *cell = (SearchCell *)[self.tableView cellForRowAtIndexPath:visibleIndexPath]; 
    NSLog(@"object ID : %@",cell.objectId); 


    cell.greyView.alpha = 0.0f; 

} 
+1

UITapGesture的什么需求? table view didSelect方法已经存在 –

回答

0
-(void) moveVideoPlayer:(UITapGestureRecognizer *)tap 
    { 
     CGPoint location = [tap locationInView:tableView]; 
     NSIndexPath *indexPath = [tableView indexPathForRowAtPoint:location]; 
     UITableViewCell *tapCell = [tableView cellForRowAtIndexPath:swipedIndexPath]; 

    //Your own code... 
} 

试试这个..

+0

你的意思是这样的? CGPoint位置= [tap locationInView:self.tableView]; NSIndexPath * indexPath = [self.tableView indexPathForRowAtPoint:location]; SearchCell * tapCell =(SearchCell *)[self.tableView cellForRowAtIndexPath:indexPath]; – durazno

+0

这是做同样的事情 - 具有相同indexPaths的所有其他单元格被选中。 – durazno

+0

您能否为我提供您的点按手势实现代码。 –