3

我正在使用 ECSliding 框架开发应用程序。一切都很顺利,直到我添加 aUItableViewController作为topViewController. 尝试滚动静态表格视图时遇到错误。我可以确定问题出在哪里,但我不知道如何解决。如果我删除下面的命令(在viewDidLoad方法中声明),我的UITableView开始正常滚动。

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

用于将 UITableViewController 设置为 topViewController 的代码

 self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Driver"];

topViewController是来自ECSlidingViewController

我在另一个帖子上发现了另一个类似的问题,但是在那里,那个人使用 aUINavigationController作为topViewController.

请让我知道是否有人可以帮我一把。

谢谢,马科斯。

4

1 回答 1

1

我看到你解决了你的问题,但是其他人也在寻找这个解决方案,所以我会提供一些关于这个的信息。

这里的问题是,当您向UITableView子类添加平移手势时,它会与当前用于滚动的手势混淆。当您平移时,它不再知道您在追求什么,并且您最终可能会出现不一致的行为(或您不想要的行为)。

有几种不同的解决方案可能会根据您的实际需求起作用:


如果你成为UIGestureRecognizerDelegate你可以实现的方法:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return TRUE;
}

这使您可以监听多个手势。只需确保将手势的委托设置为self


如果您指定希望新手势实现的方向,您可能会停止滚动问题:

   UISwipeGestureRecognizer* swipe;

   swipe = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeL)] autorelease];
   swipe.direction = UISwipeGestureRecognizerDirectionLeft;
   [view addGestureRecognizer:swipe];

   swipe = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeR)] autorelease];
   swipe.direction = UISwipeGestureRecognizerDirectionRight; // default
   [view addGestureRecognizer:swipe];

显然这是使用滑动,但它可以很容易地修改。这表示您不想担心垂直手势,您可以允许表格继续其默认行为。不过,您可能仍需要在 ONE 中实现委托方法,以验证它是否侦听多个手势。

于 2013-10-30T13:43:16.120 回答