0

I'm using Core Plot to display a scatter plot graph, and I'd like to use a swipe gesture to switch between the graph itself and a UITableView of the data the graph is made up of. My UISwipeGestureRecognizer is working fine on the table view, but the swipe events are not triggered on the graph. The graph is a UIView with class set to CPTGraphHostingView, and my code is as follows :

UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeHistoryData:)];
[swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
[graphHostingView addGestureRecognizer:swipeRight];
[tableListView addGestureRecognizer:swipeRight];

My guess is that the CPTGraphHostingView is 'eating' the swipes in some way so they are not detected by my recognizer. Can anybody comment or put me on the right road?

1
  • graphHostingView have you set the user interaction property?
    – lu yuan
    Jun 28, 2012 at 17:03

1 Answer 1

0

Sorry just figured it out - I was adding the same gesture recognizer to both the graph view and the table view. I always forget this doesn't work - because the it was added to the table view after the graph view, only the table view receives the events. I need to use 2 gesture recognizers (unless somebody can tell me different).

4
  • I think if you set the user interaction enabled of your graph view, it will recognize the gesture.
    – lu yuan
    Jun 28, 2012 at 17:10
  • It's ok the user interaction is enabled OK. It's just that 1 gesture recognizer can only be attached to 1 view control at any one time. I need to use 2 recognizers. Jun 28, 2012 at 17:13
  • Does the graph view added to the table view? Do you want both the table view and the graph to detect the swipe gesture when you swipe on the graph view? What do you really want to get?
    – lu yuan
    Jun 28, 2012 at 17:19
  • 1
    I've solved my problem thanks by using a separate recognizer for the graph and the table. I've just updated my code above to show the full code I was using. I forgot that a recognizer can only be attached to 1 view so in the code above it got set to the graph first, but then it is moved to the table so the graph no longer fired the gesture events. Jun 28, 2012 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.