Iphone - UIGestureRecognizer prevents scrolling UITableView in Xcode 4.5

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

All I did was drag and drop gesture recognition pointers from the object library to my UITableView.

If I delete them, my table will start 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 behavior, add UIGestureRecognizers programmatically, not in IB.

+6
source share
4 answers

Just try the code, please, maybe this can help you .... write the code below 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 a subclass of UIView, then use the code above, otherwise just try "youtTableview" insted from "yourView"

Hope this helps you ...

:)

+6
source

set gesture recognizer property overridesTouchesInView = NO

+1
source

I had the same problem: I used to drag my TabGestureRecognizer directly onto the storyboard instead of creating them through code. With iOS6, now this seems to break the scroll.

I prefer to add presentations, gestures, etc. directly to the storyboard, not through the code.

You can still do this, but with two changes:

1) Link to Outlet collections

  • Right-click the GestureRecognizer, which will be visible to you in the dock.
  • Clear Outlet Collection Link Section

2) Attach the GestureRecognizer to the appropriate view through the code

  • Create an outlet for your GestureRecognizer.
  • Add the following line to the viewDidLoad method:

    [self.tableView addGestureRecognizer:_tabGesture];

+1
source

I ran into the same problem and solved it by associating a gesture recognizer with a view, not a table view.

  • Show storyboard.
  • Show connection inspectors.
  • Show document outline.
  • Create a new link in the section "Links to output collections" between the recognizing gesture and view the node under the view controller.

Sincerely. Pedro.

0
source

Source: https://habr.com/ru/post/925405/


All Articles