iphone - UIGestureRecognizer阻止UITableView在Xcode 4.5中滚动 [英] iphone - UIGestureRecognizer prevents UITableView from scrolling in Xcode 4.5

查看:120
本文介绍了iphone - UIGestureRecognizer阻止UITableView在Xcode 4.5中滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have added two swipe gesture recognizers (swipe left and swipe right) to my UITableView. After that my table view has stopped scrolling. At the same time -(void)didSelectRowAtIndex works fine. What might be the problem?

我所做的只是将对象库中的滑动手势识别器拖放到我的UITableView上。

All I did is drag-and-dropped Swipe Gesture Recognizers from objects library onto my UITableView.

我删除它们,我的表开始再次滚动。

If I remove them, my table starts to scroll again.

UPD:

这发生在升级到Xcode 4.5之后。在老版本的Xcode中没有这样的问题。
为了避免这种现象,添加 UIGestureRecognizers 而不是在IB中。

This happens after upgrading to Xcode 4.5. There is no such problem in older versions of Xcode. To avoid this behaviour - add UIGestureRecognizers programatically, not in 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类的子视图,那么使用上面的代码,否则只是尝试youtTableview yourView

if here tableview is subview of UIView class then use above code otherwise just try "youtTableview" insted of "yourView"

我希望这可以帮助你...

i hope this help you...

:)

这篇关于iphone - UIGestureRecognizer阻止UITableView在Xcode 4.5中滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆