1

I've added a swipe gesture recognizer to my custom tableview cells and I thought they were working just fine, up until I tested it on a real device.

Relevant code:

//in init of the custom table view cell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) 
    {
        //other irrelevant stuff

        //leftSwipeRecognizer
        UISwipeGestureRecognizer *leftSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe_Delete)];
        [leftSwipeRecognizer setDirection:UISwipeGestureRecognizerDirectionLeft];
        [self addGestureRecognizer:leftSwipeRecognizer];

        //rightSwipeRecognizer
        UISwipeGestureRecognizer *rightSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipe_Add)];
        [rightSwipeRecognizer setDirection:UISwipeGestureRecognizerDirectionRight];
        [self addGestureRecognizer:rightSwipeRecognizer];
    }

    return self;
}

- (void) leftSwipe_Delete
{
    //never reaches this place on a real device, yet it comes here with a sim
}

- (void) rightSwipe_Add
{
    //never reaches this place on a real device, yet it comes here with a sim
}

Anyone know how what my solution might be?

4

0 回答 0