SWRevealViewController and TableView - swipe to delete not working

前端 未结 2 1982
盖世英雄少女心
盖世英雄少女心 2021-01-15 15:43

I added the SWRevealViewController to my app, along with the hamburger stack to access my menu. My app has a UITableView for the main application view. I want to allow users

相关标签:
2条回答
  • 2021-01-15 16:25

    I have done like this < UIGestureRecognizerDelegate> in .h file in which you are implementing tableview cell delete functionality and in .m file viewDidLoad

    [self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];        
    self.revealViewController.panGestureRecognizer.delegate = self;
    

    After that simply use this method

    -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
    {
    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"])
        return NO;
    else
        return YES;
    }
    
    0 讨论(0)
  • 2021-01-15 16:32

    Just found a solution after reading a thread of a guy asking a similar question to the maker of this class. Whatever class you use to add the gesture recognizers, make it the delegate of the SWRevealController then paste in this method.

    #pragma mark - SWRevealViewControllerDelegate
    
    - (BOOL)revealControllerPanGestureShouldBegin:(SWRevealViewController *)revealController
    {
        float velocity = [revealController.panGestureRecognizer velocityInView:self.view].x;
        if (velocity < 0 && self.revealViewController.frontViewPosition == FrontViewPositionLeft)
            return NO;
        else
            return YES;
    }
    
    0 讨论(0)
提交回复
热议问题