UITableViewCell上的UISwipeGestureRecognizer,不在真实设备上工作,适用于模拟器

时间:2012-09-14 09:28:35

标签: ios objective-c uitableview ios-simulator uiswipegesturerecognizer

我在我的自定义tableview单元格中添加了一个滑动手势识别器,我认为它们工作正常,直到我在真实设备上进行测试。

相关代码:

//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
}

任何人都知道我的解决方案可能是什么?

0 个答案:

没有答案