我在创建的所有单元格顶部都有黑色视图,当用户点击某个单元格时,其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;
}
答案 0 :(得分:0)
-(void) moveVideoPlayer:(UITapGestureRecognizer *)tap
{
CGPoint location = [tap locationInView:tableView];
NSIndexPath *indexPath = [tableView indexPathForRowAtPoint:location];
UITableViewCell *tapCell = [tableView cellForRowAtIndexPath:swipedIndexPath];
//Your own code...
}
试试这个..