0

I am doing some custom drawing a UITableViewCell that I have subclassed. In there there is an OpenGL ES 2.0 control that needs user interaction to work... now if I start dragging horizontally the control responds but as soon as I go in the vertical direction then it starts to move the table view's viewport. How do I stop this interaction from going to the UITableView and limit it to my own UIView in the UITableViewCell?

ExtremeCoder
  • 4,069
  • 4
  • 38
  • 55

2 Answers2

1

I don't think you can prevent user interaction on the UITableView, since it would affect all the subviews.
I'll try to send the UITableView interaction to the method you want it to use it.

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
   [MyClass myScrollDidStartMethod]; 
}

or use - (void)scrollViewDidScroll:(UIScrollView *)sender so that you can work on the sender's contentOffset to get the scrolling direction (see this post for more info about this)

Community
  • 1
  • 1
pasine
  • 10,442
  • 9
  • 44
  • 75
1

You can try to subclass UITableView and override following methods

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {  
    UITouch *touch = [touches anyObject];

    // if user tapped on your custom view, disable scroll        
        self.scrollEnabled = NO;
    // end if

    [super touchesBegan:touches withEvent:event];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    self.scrollEnabled = YES;
    [super touchesEnded:touches withEvent:event];
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
    self.scrollEnabled = YES;   
    [super touchesCancelled:touches withEvent:event];
}
Evgeny Shurakov
  • 5,972
  • 2
  • 25
  • 22