Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shouldHandlePointingDeviceDraggedEvent drags the entire View in iOS8 #114

Closed
Vasco39 opened this issue Sep 13, 2014 · 16 comments
Closed

shouldHandlePointingDeviceDraggedEvent drags the entire View in iOS8 #114

Vasco39 opened this issue Sep 13, 2014 · 16 comments
Labels

Comments

@Vasco39
Copy link

Vasco39 commented Sep 13, 2014

Hi have a CorePlot where I drag some points within the graph, after debugging the app in iOS8 when I drag the point in the graph the entire view in the navigationController is dragged and the feature of dragging is not working:

Here is the code:

- (BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDraggedEvent:(id)event atPoint:(CGPoint)point{
    NSDecimal newPoint[2];
    [plotSpaceVolume plotPoint:newPoint numberOfCoordinates:2 forPlotAreaViewPoint:point];
    NSDecimalRound(&newPoint[0], &newPoint[0], 0, NSRoundPlain);
    int x = [[NSDecimalNumber decimalNumberWithDecimal:newPoint[0]] intValue];
    int max = [[[dataForPlot objectAtIndex:[dataForPlot count]-1] objectForKey:[NSNumber numberWithInt:0]]intValue];
    int min = [[[dataForPlot objectAtIndex:0] objectForKey:[NSNumber numberWithInt:0]]intValue];

    if (x < min)
    {
        x = min;
    }
    else if (x > max)
    {
        x = max;
    }

    if (touchPlotSelected)
    {
        selectedCoordination = x;
        if ([delegate respondsToSelector:@selector(linePlot:indexLocation:)])
            [delegate linePlot:self indexLocation:x];
        [touchPlotVertical reloadData];
    }
    return YES;
}
@eskroch
Copy link
Member

eskroch commented Sep 13, 2014

Is the graph hosting view in a scroll view?

@Vasco39
Copy link
Author

Vasco39 commented Sep 13, 2014

The CPTGraphHostingView is in a UIView in the UIViewController whitch is Pushed into a UINavigationController...

@eskroch
Copy link
Member

eskroch commented Sep 13, 2014

It sounds like the superview is capturing the touch events and preventing the Core Plot hosting view from responding to them. Also, make sure allowsUserInteraction is YES on the plot space. Otherwise, it will ignore touch interaction.

@Vasco39
Copy link
Author

Vasco39 commented Sep 14, 2014

I agree it sounds like the superview is capturing the touch events and instead of the hosting view.
I've done what you suggest but the result is the same...

@Vasco39
Copy link
Author

Vasco39 commented Sep 14, 2014

I solved the problem of the navigationcontroller swipe with
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
Now the problem is that I have a Plot space where I want do drag only a single point (not the entire graph), if I set to yes the allowsUserInteraction the entire graph is moving, and if I let it to NO the graph is not taking the shouldHandlePointingDeviceDownEvent event. In iOS 7 this worked.... Any suggestion?

@eskroch
Copy link
Member

eskroch commented Sep 14, 2014

I don't understand what you mean by moving only a single point. What does the -linePlot:indexLocation: delegate method do?

@Vasco39
Copy link
Author

Vasco39 commented Sep 14, 2014

I have this situation and I have to move only the white point to te right side...

screen shot 2014-09-14 at 2 44 45 pm
Before iOS 8 this worked, now if I swipe with allowsUserInteraction: YES the entire graph moves not only the white point...

@eskroch
Copy link
Member

eskroch commented Sep 14, 2014

Is your delegate method (the one in the question above) being called? If so, it should capture the event and prevent the plot space from scrolling. Did you change anything else in the app, or does the same version work on iOS 7 but not on iOS 8?

@Vasco39
Copy link
Author

Vasco39 commented Sep 14, 2014

No the linePlot:indexLocation:and the shouldHandlePointingDeviceDraggedEventare not called.

With iOS 7 are working and 8 not...

I've made only this change [plotSpaceVolume plotPoint:newPoint numberOfCoordinates:2 forPlotAreaViewPoint:point];but I don't think is relevant, as it is located in the shouldHandlePointingDeviceDraggedEvent function...

@Vasco39
Copy link
Author

Vasco39 commented Sep 14, 2014

When I arrive to

(void)scatterPlot:(CPTScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:(NSUInteger)index{
if ([(NSString *)plot.identifier isEqualToString:kLinePlot]){
touchPlotSelected = YES;
if ([delegate respondsToSelector:@selector(linePlot:indexLocation:)])
[delegate linePlot:self indexLocation:index];
} }

the delegate (id) is 0x0 and it steps over... Is it relevant?

@eskroch
Copy link
Member

eskroch commented Sep 14, 2014

Yes. Objects normally hold weak references to their delegates to prevent retain cycles. Core Plot does this, too, for that reason. It looks like your delegate is going away because nothing is holding a strong reference to it.

@Vasco39
Copy link
Author

Vasco39 commented Sep 14, 2014

Yes actually adding
plotSpaceVolume.allowsUserInteraction = YES; plotSpaceVolume.delegate = self;
the linePlot:indexLocation: and the shouldHandlePointingDeviceDraggedEvent are called, but the data on the graph disappears.
screen shot 2014-09-14 at 10 00 43 pm

If I comment out plotSpaceVolume.delegate = self; appears but the methods are not fired.

I can't figure out where is the problem...

@eskroch
Copy link
Member

eskroch commented Sep 14, 2014

What is self? Is it both the delegate and datasource? Does some other object maintain a strong reference to it?

@Vasco39
Copy link
Author

Vasco39 commented Sep 15, 2014

Can I send you the entire class source code privately to verify and then we'll post the answer here?

@Vasco39
Copy link
Author

Vasco39 commented Sep 15, 2014

I can't figure out how to solve it...

@Vasco39
Copy link
Author

Vasco39 commented Sep 15, 2014

I solved...
I had to place the plotSpaceVolume.delegate = self; after the creation of the graph and scatters (after everything,...

@eskroch eskroch closed this as completed Sep 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants