Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu for cell doesn't appear #184

Open
Isuru-Nanayakkara opened this issue Jul 7, 2014 · 3 comments
Open

Menu for cell doesn't appear #184

Isuru-Nanayakkara opened this issue Jul 7, 2014 · 3 comments

Comments

@Isuru-Nanayakkara
Copy link

Hi,

I have implemented the following 3 delegate methods for UITableView to show a copy menu item to copy a cell.

- (void)tableView:(UITableView*)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath*)indexPath withSender:(id)sender {

    if (action == @selector(copy:)) {
        if (action == @selector(copy:)) {
        SWTableViewCell *cell = (SWTableViewCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];
        self.copiedName = cell.textLabel.text;

        [self.items insertObject:self.copiedName atIndex:indexPath.row];
        NSIndexPath *path = [NSIndexPath indexPathForRow:indexPath.row inSection:0];

        [self.tableView beginUpdates];
        [tableView insertRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationBottom];
        [self.tableView endUpdates];
    }
}

- (BOOL)tableView:(UITableView*)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath*)indexPath withSender:(id)sender {

    if (action == @selector(copy:)) {
        return YES;
    }

    return NO;
}

- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath*)indexPath {
    return YES;
}

This works just fine in normal UITableViewCells. But when using SWTableViewCell, that little copy menu doesn't show up. I put breakpoints at each of these methods but none of them gets fired even.

Can anyone please tell me why this is happening and possibly a way to fix this?

Many thanks.

EDIT 1: I looked through the source files in SWTableViewCell and it seems there's a special long press gesture recognizer class. Since the copy menu appears when long pressing on a cell too, the cause might be this long press gesture is interfering with that, I guess? Is there any way to turn off the SWLongPressGestureRecognizer?

EDIT 2: I commented out the following code block from SWTableViewCell.m file and as expected my issue was resolved.

self.longPressGestureRecognizer = [[SWLongPressGestureRecognizer alloc] initWithTarget:self action:@selector(scrollViewPressed:)];
self.longPressGestureRecognizer.cancelsTouchesInView = NO;
self.longPressGestureRecognizer.minimumPressDuration = kLongPressMinimumDuration;
self.longPressGestureRecognizer.delegate = self;
[self.cellScrollView addGestureRecognizer:self.longPressGestureRecognizer];

But I'd rather do this in a non-hackish way because I'm not sure weather that long press is an essential part for the control to work. So my question still stands.

@jose920405
Copy link

I have the same problem.. Any help?

@jose920405
Copy link

@Isuru-Nanayakkara Man i currently not user the long press functionality in the library. I comment this functionality and it worked for now

@mshibanami
Copy link

+1
I have a similar issue.
In UITextView on SWTableViewCell, Selecting text with the long press is not working.

(Currently I avoid the problem with this.
But essentially it's the same as the comment out of @Isuru-Nanayakkara.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants