1

How can make custom button for moving rows in UITable?

I would like it to be transparent. (Instead of this: enter image description here )

Another thing is, when the cell is moved, it has shadow. Is it possible to remove it?

2 Answers 2

2

Try this...

You have to do this by subclassing UITableViewCell and overriding its setEditing:animated: method as follows:

The re-order control is a UITableViewCellReorderControl, but that's a private class, so you can't access it directly.

you could just look through the hierarchy of subviews and find its imageView.

- (void) setEditing:(BOOL)editing animated:(BOOL)animated
{
    [super setEditing: editing animated: YES];

    if (editing) {

        for (UIView * view in self.subviews) {
            if ([NSStringFromClass([view class]) rangeOfString: @"Reorder"].location != NSNotFound) {
                for (UIView * subview in view.subviews) {
                    if ([subview isKindOfClass: [UIImageView class]]) {
                        ((UIImageView *)subview).image = [UIImage imageNamed: @"yourimage.png"];
                    }
                }
            }
        }
    }   
}
3
  • I have an error on the line: "for (UIView * view in self.subviews)" It sais- "Property 'subviews' not found on object of type myController"
    – Luda
    Jan 24, 2013 at 14:18
  • Read the Text which i highlight in bold. i think you have wrote this method..in your view controller.....where you have written tableview methods.
    – Wolverine
    Jan 24, 2013 at 16:32
  • Have you a solution for ios 8? Sep 24, 2014 at 9:57
1

You can turn off the reordering control by setting -[UITableViewCell setShowsReorderControl:] to NO. After that you will need your own custom reordering implementation. I'm not sure what you can do about the shadow effect during a move.

If you really want to dig deep you can create your custom table view cell move UX.

3
  • If I'll set setShowsReorderControl to NO. I won't be able to edit, or would I?
    – Luda
    Jan 24, 2013 at 14:14
  • @Luda You have to roll your own move. Attach a UIPanGestureRecognizer to a cell, on first touch remove that cell from the table, add the cell to the windows right where the user is touching it. As the user pans move the cell to keep it under the user's finger. Jan 24, 2013 at 18:09
  • @Luda I didn't say it would be easy. Jan 24, 2013 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.