我正在使用 ECSliding 框架开发应用程序。在我将 UItableViewController
添加为 topViewController
之前,一切都很顺利。我在尝试滚动静态 TableView 时遇到错误。我可以确定问题出在哪里,但我不知道如何解决。如果我删除下面的命令(在 viewDidLoad
方法中声明),我的 UITableView
开始正常滚动。
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
用于将 UITableViewController 设置为 topViewController 的代码
self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Driver"];
topViewController
是 ECSlidingViewController
我在另一篇文章中发现了另一个类似的问题,但是在那儿,那个人正在使用 UINavigationController
作为 topViewController
。
如果有人可以帮助我,请告诉我。
谢谢, 马科斯。
最佳答案
我看到您解决了您的问题,但根据评论,其他人也在寻找此解决方案,因此我将提供一些相关信息。
这里的问题是,当您向 UITableView
子类添加平移手势时,它会扰乱当前用于滚动的手势。当您平移时,它不再知道您在追求什么,您最终可能会出现不一致的行为(或您不想要的行为)。
有几种不同的解决方案可能会根据您的实际需求起作用:
ONE :
如果您成为UIGestureRecognizerDelegate
,您可以实现该方法:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return TRUE;
}
这允许您监听多个手势。只需确保将手势的委托(delegate)设置为 self
TWO :
如果您指定希望新手势实现的方向,您可能会停止滚动问题:
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 中实现委托(delegate)方法,以验证它是否监听多个手势。
关于ios - 带静态 UITableView 的 ECSlidingViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15713746/