How to add Swipe Gestures to UITableView cell?

前端 未结 3 1239
别那么骄傲
别那么骄傲 2020-12-14 03:28

I added this code in cellForRowAtIndexPath

UISwipeGestureRecognizer *gestureR = [[UISwipeGestureRecognizer alloc]
                                       


        
3条回答
  •  萌比男神i
    2020-12-14 04:33

    Try this

    UISwipeGestureRecognizer* gestureR;
    gestureR = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom)] autorelease];
    gestureR.direction = UISwipeGestureRecognizerDirectionLeft;
    [view addGestureRecognizer:gestureR];
    
    gestureR = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom)] autorelease];
    gestureR.direction = UISwipeGestureRecognizerDirectionRight; // default
    [view addGestureRecognizer:gestureR];
    

    If you want to handle different functionalities on left and right swipes, just change the selectors.

提交回复
热议问题