ios - 带静态 UITableView 的 ECSlidingViewController

标签 ios objective-c uitableview

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

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

用于将 UITableViewController 设置为 topViewController 的代码

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

topViewControllerECSlidingViewController

的属性

我在另一篇文章中发现了另一个类似的问题,但是在那儿,那个人正在使用 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/

相关文章:

ios - 按停止按钮时 AVAudioPlayer 不恢复

ios - 为什么 awakeFromNib 从 TableView 中的 Cell 调用两次?

iphone - 获取连接到 LAN 的设备的 IP 地址/MAC 地址

ios - 将 Json 值传递给其他 ViewController?

ios - 是否可以仅使用 NSURLSession 为 UITableViews 构建异步图像下载机制?如何?

iOS - 检测 UITableViewCell 被移出可见 View ?

ios - AnyObject 没有名为 "sort"的成员

ios - 如果设备被锁定,CADislayLink 不会触发

android - 应用程序在 Android 上的呈现方式与使用 phonegap 的 iOS 不同

ios - 计算一下我在 SpriteKit 中失败的游戏次数?