0
我想使左右滑动并单击tableview单元格的行为完全相同。我找不到直接回答这个..在tableviewcontroller中选择一行并向左滑动表现相同
我有一个的tableView和下面的代码,以确保电池高亮发生在点击
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self selectRowAtIndexPath:indexPath];
}
- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (void)setCellColor:(UIColor *)color ForCell:(UITableViewCell *)cell {
cell.contentView.backgroundColor = color;
cell.backgroundColor = color;
}
- (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
// Add your Colour.
[self setCellColor:[UIColor colorWithWhite:0.961 alpha:1.000] ForCell:[tableView cellForRowAtIndexPath:indexPath]]; //highlight colour
}
- (void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath {
// Reset Colour.
[self setCellColor:[UIColor whiteColor] ForCell:[tableView cellForRowAtIndexPath:indexPath]]; //normal color
}
我也有上向左滑动的手势下面的代码一个单元格
- (void)handleSwipeLeft:(UISwipeGestureRecognizer *)gestureRecognizer
{
//Get location of the swipe
CGPoint location = [gestureRecognizer locationInView:self.tblView];
//Get the corresponding index path within the table view
NSIndexPath *indexPath = [self.tblView indexPathForRowAtPoint:location];
//Check if index path is valid
if(indexPath)
{
[self.tblView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[self.tblView.delegate tableView:self.tblView didSelectRowAtIndexPath:indexPath];
}
}
滑动手势正常发生,即它的行为与点击相同,但不会突出显示该单元格。我试图通过设置单元格的颜色来强制左侧滑动手势中的高光,但它仍然不起作用。有什么建议么 ?谢谢