Crash on single tap 2.9.0.6


#1

Just upgraded to 2.9.0.6 and I am getting crashes everytime I do a single tap on my chart. Do you know something about this?

Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[SChartLineSeries innerRadius]: unrecognized selector sent to instance 0x101ca7f00’


#2

Hi siper,

I can’t reproduce this, I’ve tried with crosshair enabled, and different selection modes for my series. Are you able to modify one of our samples to send us a demo?

Thanks!


#3

The problem occurs when you add your own gesture recognizer for single tap. I did not call inner radius myself.

for (UIGestureRecognizer *gesture in _chart.canvas.overlay.gestureRecognizers) {
if([gesture isKindOfClass:[UITapGestureRecognizer class]]){
gesture.delegate = self;
}
}


#4

Hi siper,

In the latest version we implemented UIGestureRecognizerDelegates internally and assigned one to all our gesture recognizers.

So the crash you are seeing is caused when you override our internal delegates.

To prevent the crash, you can replace your gesture recognizer loop with the following code:

chart.gestureManager.radialTapGesture.enabled = NO;
chart.gestureManager.doubleTapGesture.delegate = self;
chart.gestureManager.singleTapGesture.delegate = self;

However, can I ask what you are using the gesture delegate for?

As I want to make sure the above code is the most robust solution.

Kind regards,
Andrew Polkinghorn.


#5

I am using the single tap to toggle full screen mode. The new code looks a lot cleaner, so that is good :wink: I’ll give it a shot. Is there any default behavior I will miss out on by disabling the radialTapGesture?


#6

Hi siper,

Disabling the radialTapGesture will have no impact unless your chart displays pie/donut series, which by the sounds of it, it does not.

However, rather than reassigning the `singleTapGesture’s delegate the following might be slightly more future-proof ways of detecting a tap on the chart:

// Add a new target when a single tap gesture is detected
[_chart.gestureManager.singleTapGesture addTarget:self action:@selector(tapped)];
// Create your own tap recognizer and add it to the chart
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped)];
tapRecognizer.delegate = self; // Important to set the delegate
[_chart addGestureRecognizer:tapRecognizer];

// To allow your and the chart's single tap gesture recognizer to co-exist peacefully, we'll need to say that both can be detected at the same time
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}

Anyway, I hope one of solutions we’ve provided works well for you :slight_smile: