Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 views
in Technique[技术] by (71.8m points)

objective c - iphone - UIGestureRecognizer prevents UITableView from scrolling in Xcode 4.5

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?

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:

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

just try bellow code may this help you.... write bellow code in viewDidLoad: method

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];

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

i hope this help you...

:)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...