ECSlidingViewController禁用在UITableView中滑动删除

时间:2013-09-02 18:16:30

标签: ios objective-c uitableview ecslidingviewcontroller

我正在使用此源代码添加类似于Facebook App的滑动菜单:

Git Hub项目ECSlidingViewController:https://github.com/edgecase/ECSlidingViewController

以下是我的自定义UINavigation控制器的代码:

@implementation NavViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    if (![self.slidingViewController.underLeftViewController isKindOfClass:[ZAPMenuViewController class]])
    {
        self.slidingViewController.underLeftViewController  = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
    }

    [self.view addGestureRecognizer:self.slidingViewController.panGesture];
}

但是,我有一个UITableView,我需要能够滑动删除。有没有办法在向左滑动时禁用panGesture,但是让panGesture向右滑动并显示菜单?

2 个答案:

答案 0 :(得分:2)

另请查看ECSlidingViewController的wiki上的一些答案,其中包括允许同时识别手势。

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer
 *)otherGestureRecognizer {
     if ([otherGestureRecognizer.view isKindOfClass:[UIScrollView class]]) {
         return YES;
     } else {
         return NO;
     } }

答案 1 :(得分:0)

作为一种解决方法,您可以使用置于控制器“背景”中的UIView并将panGesture连接到它。而不是

[self.view addGestureRecognizer:self.slidingViewController.panGesture];

我用过UIView outlet

@property (strong, nonatomic) IBOutlet UIView *slideOutArea;

然后以适当的方法,如viewWillAppear

[self.slideOutArea addGestureRecognizer:self.slidingViewController.panGesture];