iphone - UIGestureRecognizer 阻止 UITableView 在 Xcode 4.5 中滚动

标签 iphone objective-c xcode cocoa-touch uigesturerecognizer

我在我的 UITableView 中添加了两个滑动手势识别器(向左滑动和向右滑动)。之后我的表格 View 停止滚动。同时 -(void)didSelectRowAtIndex 工作正常。 可能是什么问题?

我所做的只是将 Swipe Gesture Recognizers 从对象库拖放到我的 UITableView 上。

如果我删除它们,我的表格会再次开始滚动。

更新:

升级到 Xcode 4.5 后会发生这种情况。在旧版本的 Xcode 中没有这样的问题。 要避免此行为 - 以编程方式添加 UIGestureRecognizers,而不是在 IB 中。

最佳答案

试试下面的代码可能对你有帮助.... 在viewDidLoad:方法

中编写如下代码
UISwipeGestureRecognizer *swipeGestureObjectImg = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(yourSlideOpen_Clicked:)] autorelease];//yourSlideOpen_Clicked is method name where you doing something
swipeGestureObjectImg.numberOfTouchesRequired = 1;
swipeGestureObjectImg.direction = (UISwipeGestureRecognizerDirectionLeft);
[yourView addGestureRecognizer:swipeGestureObjectImg];

UISwipeGestureRecognizer *swipeGestureRightObjectImg = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(yourSlideClose_Clicked:)] autorelease];//yourSlideClose_Clicked is method name where you doing something
swipeGestureRightObjectImg.numberOfTouchesRequired = 1;
swipeGestureRightObjectImg.direction = (UISwipeGestureRecognizerDirectionRight);
[yourView addGestureRecognizer:swipeGestureRightObjectImg];

如果此处的 tableview 是 UIView 类的 subview ,则使用上面的代码,否则只需尝试将“youtTableview”替换为“yourView”

希望对你有帮助...

:)

关于iphone - UIGestureRecognizer 阻止 UITableView 在 Xcode 4.5 中滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12423253/

相关文章:

ios - 如何在 < iPhone5 和 swift 中使用长值

ios - 从 Objective-C 到 Swift 的桥接后无法识别扩展

iphone - 如何在代码中更改 UIBarButtonItem 的样式

ios - 成功调用 api 后未调用 cellForRowAtIndexPath

android - cordova 7.0.1 iOS 构建失败

php - 在智能手机和平板电脑中使用 header() 强制使用 php 下载图像

javascript - Onclick 无法使用 html 在 iphone 中的列表上工作

iOS 应用程序评论 - 视频流 MPEG-DASH 时间超过 10 分钟

iphone - Xcode 4.1 工具几乎不适合我

ios - Swift 中基于图像的动画