Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 无法选择正确单元格的正确内容_Objective C_Tableview_Cell - Fatal编程技术网

Objective c 无法选择正确单元格的正确内容

Objective c 无法选择正确单元格的正确内容,objective-c,tableview,cell,Objective C,Tableview,Cell,我在创建的所有单元格顶部都有黑色视图,当用户点击某个单元格时,它的alpha值变为0.0f 我一直在努力解决的是,单元格重用标识符,因此当我更改某个单元格的某些内容时,其他一些单元格的内容也会被编辑,因为它们共享相同的索引 如何访问特定单元格的内容 这就是我正在做的- UITapGestureRecognizer *videoGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(moveVide

我在创建的所有单元格顶部都有黑色视图,当用户点击某个单元格时,它的alpha值变为0.0f

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

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

这就是我正在做的-

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;

}

试试这个..

你是说像这样?CGPoint location=[点击位置视图:self.tableView];NSIndexPath indexPath=[self.tableView indexPathForRowAtPoint:location];SearchCell*tapCell=SearchCell[self.tableView cellforrowatinexpath:indexPath];这是在做同样的事情-所有其他具有相同索引路径的单元格都被选中。能否请您向我提供您的点击手势实现代码。根据我的经验,要获得特定单元格,请按其行号进行搜索。我很久以前就做过这样的事,但现在已经忘记了。。我不认为我可以只用indexath.is your self.optionview是tableview对象来完成这项工作。如果是,则使用SearchCell*tapCell=SearchCell[self.optionview CellForRowatineXpath:indexPath];需要什么样的手势?表视图已存在选择方法
 -(void) moveVideoPlayer:(UITapGestureRecognizer *)tap
  {
       CGPoint location = [tap locationInView:tableView];
      NSIndexPath *indexPath = [tableView  indexPathForRowAtPoint:location];
       UITableViewCell *tapCell = [tableView cellForRowAtIndexPath:swipedIndexPath];

     //Your own code...
 }