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

Only Swipe Gesture will work #1

Closed
Soumin opened this issue Oct 8, 2013 · 8 comments
Closed

Only Swipe Gesture will work #1

Soumin opened this issue Oct 8, 2013 · 8 comments

Comments

@Soumin
Copy link

Soumin commented Oct 8, 2013

Great job. Its exactly what I was looking for. But if I implement this cell, I can only have right swipe or left swipe. Selecting a row gesture will not work. Can you improve this so that other gesture like selecting the cell?

CEWendel added a commit that referenced this issue Oct 8, 2013
@CEWendel
Copy link
Owner

CEWendel commented Oct 8, 2013

Sorry, ignore that commit. I am working on this hopefully today, in the mean time you can add a UITapGestureRecognizer to the top UIScrollView in the SWTableViewCell to capture selection.

@Soumin
Copy link
Author

Soumin commented Oct 8, 2013

I add a UITapGestureRecognizer to SWTableViewCell.

Added a delegate method to SWTableViewCellDelegate

  • (void)didSelectCell:(SWTableViewCell *)cell;

@mbigatti
Copy link

mbigatti commented Oct 9, 2013

Hi. Just to say that I had to implement am heavy workaround for a similar component https://github.com/mbigatti/BMXSwipableCell. Hope you'll find a better solution

@morteza2128
Copy link

@Soumin can you explain more?

@lorenzopicoli
Copy link

Workaround:
in SWTableViewCell.h add the following delegate method:

@protocol SWTableViewCellDelegate
...

  • (void)didSelectedCell:(SWTableViewCell *)cell;
    @EnD

    in SWTableViewCell.m. Inside the method initializer add the following code:

  • (void)initializer {
    ...
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapedInsideCell)];
    tap.cancelsTouchesInView = NO;
    [self addGestureRecognizer:tap];
    }

and create the following method:

  • (void) tapedInsideCell{
    if ( _cellState == kCellStateCenter) {
    [ _delegate didSelectedCell:self];

    }
    }

then, in the view controller where the tableView is located add the code.

  • (void)didSelectedCell:(SWTableViewCell *)cell{

    NSIndexPath *indexPath = [ _myTable indexPathForCell:cell];
    [self tableView: _myTable didSelectRowAtIndexPath:indexPath];

}

Now the method didSelectRowAtIndexPath will be called when you tap inside a cell

@CEWendel
Copy link
Owner

CEWendel commented Oct 9, 2013

This should be fixed now. It behaves like the iOS 7 mail app where the cell will be selected if the utility buttons are not visible, but if they are touching the cell will simply scroll it back into place. I still need to add the touch highlight.

@laud
Copy link
Contributor

laud commented Oct 11, 2013

First off, great library. Learning tons from it.

I'd also be interested in figuring out a solution to do cell highlighting. Why has cell selection highlighting disappeared? Subview ordering?

I also found it weird that the library was asking for the cell's indexPath. Wouldn't you want to use
NSIndexPath *indexPath = [self.containingTableView indexPathForCell:self]; instead? I found that trying to use the indexPath assigned at init becomes invalid when cells get deleted.

@CEWendel
Copy link
Owner

Yea I actually plan to implement cell highlighting tonight. The reason its not there right now is I actually have my own UITapGestureRecognizer that gets fired on the selection of the cell so it can implement smart selection. Just have been too busy to implement cell highlighting the last week.

Also I completely forgot UITableView had that method. Feel free to send a pull request

CEWendel pushed a commit that referenced this issue Dec 6, 2013
hide the swipe menu when all the elements have a clear background
anivaros pushed a commit to anivaros/SWTableViewCell that referenced this issue Jun 22, 2018
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

6 participants