This question is locked. New answers and comments are not allowed.
I added a TKChart to a UIScrollView, the scroll worked properly, but when I pinch/pan my chart it barely worked.
Sometimes when i pinch the chart, it just shifting, and when i pan it, it zooming in/out. And sometimes the chart can't be zoomed/panned at all.
When i put the chart outside UIScrollView, zoom & pan worked properly.
How to solve this?
Sometimes when i pinch the chart, it just shifting, and when i pan it, it zooming in/out. And sometimes the chart can't be zoomed/panned at all.
When i put the chart outside UIScrollView, zoom & pan worked properly.
How to solve this?
4 Answers, 1 is accepted
0
Hello Muhammad,
I have just tried to reproduce the problem I have placed a TKChart inside a UIScrollView . So far it seems to work as expected.
Can you please share any details ( e.g. code ) that might help reproduce the issue ? Once I am able to reproduce the problem I believe I can provide a solution or a workaround for you .
Regards,
Pavel Pavlov
Telerik
I have just tried to reproduce the problem I have placed a TKChart inside a UIScrollView . So far it seems to work as expected.
Can you please share any details ( e.g. code ) that might help reproduce the issue ? Once I am able to reproduce the problem I believe I can provide a solution or a workaround for you .
Regards,
Pavel Pavlov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Muhammad
Top achievements
Rank 1
answered on 18 Dec 2014, 07:24 AM
This reproduce the problem:
(btw why there's no Objective-C option in Format Code Block?)
I think the problem's occured because when I pinch/swipe the chart, there's conflict between chart's gesture detector and scrollview's one. So maybe I must make each detector exclusive (how to do this?). Or is there any better solution?
Sorry for my bad english btw
(btw why there's no Objective-C option in Format Code Block?)
01.
#import "ViewController.h"
02.
#import <TelerikUI/TelerikUI.h>
03.
04.
@
interface
ViewController ()
05.
@property (strong, nonatomic) UIScrollView *scrollView;
06.
@property (strong, nonatomic) TKChart *chart;
07.
@end
08.
09.
@implementation ViewController
10.
11.
- (
void
)viewDidLoad {
12.
[super viewDidLoad];
13.
// Do any additional setup after loading the view, typically from a nib.
14.
// Adding scrollview
15.
self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, self.navigationController.navigationBar.frame.size.height, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame))];
16.
[self.scrollView setUserInteractionEnabled:YES];
17.
[self.scrollView setBackgroundColor:[UIColor blackColor]];
18.
[self.scrollView setContentSize:CGSizeMake(CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame) + 1000)];
19.
[self.view addSubview:self.scrollView];
20.
21.
// Adding chart
22.
self.chart = [[TKChart alloc] initWithFrame:CGRectInset(self.view.bounds, 150, 150)];
23.
self.chart.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
24.
[self.scrollView addSubview:self.chart];
25.
26.
// Set data
27.
NSMutableArray *randomNumericData = [[NSMutableArray alloc] init];
28.
for
(
int
i = 0; i < 10; i++) {
29.
[randomNumericData addObject:[[TKChartDataPoint alloc] initWithX:@(i) Y:@(arc4random()%100)]];
30.
}
31.
32.
[self.chart addSeries:[[TKChartLineSeries alloc] initWithItems:randomNumericData]];
33.
self.chart.title.hidden = NO;
34.
self.chart.title.text = @
"Grafik yeah"
;
35.
self.chart.legend.hidden = NO;
36.
self.chart.allowAnimations = YES;
37.
self.chart.xAxis.allowZoom = YES;
38.
}
39.@end
I think the problem's occured because when I pinch/swipe the chart, there's conflict between chart's gesture detector and scrollview's one. So maybe I must make each detector exclusive (how to do this?). Or is there any better solution?
Sorry for my bad english btw
0
Hello Muhammad,
Thanks for sharing the code. I have put it in a project but I am afraid I still can not reproduce the issue.
What I have done - I have pasted your code into a view controllers viewDidLoad method.
I have just changed the size in the following line :
as the chart was not displayed well.
What I observed :
I could pinch zoom the chart and later pan it with no problem.
Am I missing something , e.g some steps to reproduce the issue ?
Do you get it in a simulator or on a real device ( device version , iOS version).
*I assume you are working with version 2014.3 1024 of our iOS controls suite.
Regards,
Pavel Pavlov
Telerik
Thanks for sharing the code. I have put it in a project but I am afraid I still can not reproduce the issue.
What I have done - I have pasted your code into a view controllers viewDidLoad method.
I have just changed the size in the following line :
self.chart = [[TKChart alloc] initWithFrame:CGRectMake(0,0,150,150)];
as the chart was not displayed well.
What I observed :
I could pinch zoom the chart and later pan it with no problem.
Am I missing something , e.g some steps to reproduce the issue ?
Do you get it in a simulator or on a real device ( device version , iOS version).
*I assume you are working with version 2014.3 1024 of our iOS controls suite.
Regards,
Pavel Pavlov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Muhammad
Top achievements
Rank 1
answered on 13 Jan 2015, 12:37 PM
Hello Pavel,
I updated the framework to the latest update, and it worked well. Thank you :)
I updated the framework to the latest update, and it worked well. Thank you :)