Utilizzo di CorePlot versione 1.6. iOS in esecuzione 8.3.Lo scorrimento di iOS Core-Plot non funziona correttamente
Sto utilizzando Core-Plot con ScatterPlot per rappresentare le linee multiple. Quando si scorre, il grafico si sposta su salti e si blocca. Non so cosa succede Mi potete aiutare? Ecco il mio codice:
#import <UIKit/UIKit.h>
#import "CorePlot-CocoaTouch.h"
@interface TemporalLineViewController:UIViewController<CPTPlotDataSource,
CPTScatterPlotDelegate>
@property (strong, nonatomic) IBOutlet CPTGraphHostingView *hostingView;
@end
@interface TemporalLineViewController(){
NSMutableDictionary *dates;
}
@property (nonatomic, readwrite, strong) NSArray *plotData;
@end
@implementation TemporalLineViewController
-(CPTGraph *)createGraph{
initWithFrame:CGRectMake(viewGraph.frame.origin.x, viewGraph.frame.origin.y, 500, viewGraph.frame.size.height)];
CPTGraph *graph = [[CPTXYGraph alloc] initWithFrame:hostingView.bounds];
[graph applyTheme:[CPTTheme themeNamed:kCPTSlateTheme]];
hostingView.hostedGraph=graph;
// Axes
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTXYAxis *x = axisSet.xAxis;
x.majorIntervalLength = CPTDecimalFromDouble(ONEDAY);
x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(0.0);
x.minorTicksPerInterval = 0;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd/MM/yyyy"];
CPTTimeFormatter *timeFormatter = [[CPTTimeFormatter alloc] initWithDateFormatter:dateFormatter];
timeFormatter.referenceDate = [[NSDate alloc]init];
x.labelFormatter = timeFormatter;
x.labelRotation = CPTFloat(M_PI_4);
CPTXYAxis *y = axisSet.yAxis;
y.hidden=YES;
y.orthogonalCoordinateDecimal = CPTDecimalFromInt(0);
return graph;
}
-(void)createScatterPlot{
CPTGraph * graph = [self createGraph];
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
NSTimeInterval xLow = 0.0;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(xLow) length:CPTDecimalFromDouble(ONEDAY * 10.0)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(-1) length:CPTDecimalFromDouble(5.0)];
plotSpace.allowsUserInteraction = YES;
plotSpace.allowsMomentum = YES;
CPTScatterPlot *diagnosticPlot = [self createScatterPlotWithIdentifier:DIAGNOSTIC_PLOT withLineColor:[CPTColor greenColor] withFillColor:[CPTColor greenColor]];
CPTScatterPlot *vaccinePlot = [self createScatterPlotWithIdentifier:VACCINE_PLOT withLineColor:[CPTColor blackColor] withFillColor:[CPTColor blackColor]];
CPTScatterPlot *interventionPlot = [self createScatterPlotWithIdentifier:INTERVENTION_PLOT withLineColor:[CPTColor blueColor] withFillColor:[CPTColor blueColor]];
CPTScatterPlot *smokingHabitPlot = [self createScatterPlotWithIdentifier:SMOKING_HABIT_PLOT withLineColor:[CPTColor yellowColor] withFillColor:[CPTColor yellowColor]];
CPTScatterPlot *menstrualPlot = [self createScatterPlotWithIdentifier:MENSTRUAL_PLOT withLineColor:[CPTColor redColor] withFillColor:[CPTColor redColor]];
CPTScatterPlot *menstrualTreatmentPlot = [self createScatterPlotWithIdentifier:MENSTRUAL_TREATMENT_PLOT withLineColor:[CPTColor orangeColor] withFillColor:[CPTColor orangeColor]];
CPTScatterPlot *psychomotorMilestonePlot = [self createScatterPlotWithIdentifier:PSYCHOMOTOR_MILESTONE_PLOT withLineColor:[CPTColor purpleColor] withFillColor:[CPTColor purpleColor]];
[graph addPlot:vaccinePlot toPlotSpace:plotSpace];
[graph addPlot:diagnosticPlot toPlotSpace:plotSpace];
[graph addPlot:interventionPlot toPlotSpace:plotSpace];
[graph addPlot:smokingHabitPlot toPlotSpace:plotSpace];
[graph addPlot:menstrualPlot toPlotSpace:plotSpace];
[graph addPlot:menstrualTreatmentPlot toPlotSpace:plotSpace];
[graph addPlot:psychomotorMilestonePlot toPlotSpace:plotSpace];
}
-(CPTScatterPlot *)createScatterPlotWithIdentifier:(NSString *)identifier withLineColor:(CPTColor *)lineColor withFillColor:(CPTColor *) fillColor{
CPTScatterPlot *dataSourceLinePlot = [[CPTScatterPlot alloc] init];
dataSourceLinePlot.identifier = identifier;
CPTMutableLineStyle *lineStyle = [dataSourceLinePlot.dataLineStyle mutableCopy];
lineStyle.lineWidth = 3.0;
lineStyle.lineColor = lineColor;
dataSourceLinePlot.dataLineStyle = lineStyle;
CPTPlotSymbol *plotSymbol2 = [CPTPlotSymbol ellipsePlotSymbol];
plotSymbol2.fill = [CPTFill fillWithColor:fillColor];
plotSymbol2.size = CGSizeMake(10.0, 10.0);
dataSourceLinePlot.plotSymbol = plotSymbol2;
return dataSourceLinePlot;
}
-(void)generateData{
NSMutableArray *data = [NSMutableArray array];
[data addObject:[self createDiagnosticData]];
[data addObject:[self createVaccineData]];
[data addObject:[self createInterventionData]];
[data addObject:[self createSmokingHabitData]];
[data addObject:[self createMenstrualData]];
[data addObject:[self createMenstrualTreatmentData]];
[data addObject:[self createPsychomotorMilestoneData]];
self.plotData = data;
}
#pragma mark -
#pragma mark Plot Data Source Methods
-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot
{
NSLog(@"numberOfRecordsForPlot");
if ([plot.identifier isEqual:DIAGNOSTIC_PLOT]) {
NSMutableArray *data = self.plotData[0];
return data.count;
}else if([plot.identifier isEqual:VACCINE_PLOT]){
NSMutableArray *data = self.plotData[1];
return data.count;
} else if([plot.identifier isEqual:INTERVENTION_PLOT]){
NSMutableArray *data = self.plotData[2];
return data.count;
} else if([plot.identifier isEqual:SMOKING_HABIT_PLOT]){
NSMutableArray *data = self.plotData[3];
return data.count;
} else if([plot.identifier isEqual:MENSTRUAL_PLOT]){
NSMutableArray *data = self.plotData[4];
return data.count;
} else if([plot.identifier isEqual:MENSTRUAL_TREATMENT_PLOT]){
NSMutableArray *data = self.plotData[5];
return data.count;
} else if([plot.identifier isEqual:PSYCHOMOTOR_MILESTONE_PLOT]){
NSMutableArray *data = self.plotData[6];
return data.count;
}
return 0;
}
-(id)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
NSLog(@"numberForPlot");
if ([plot.identifier isEqual:DIAGNOSTIC_PLOT]) {
NSMutableArray *data = self.plotData[0];
NSString *str = [NSString stringWithFormat:@"%@",(data[index][@(fieldEnum)])];
if ([str intValue]==0) {
return nil;
}
return data[index][@(fieldEnum)];
}else if([plot.identifier isEqual:VACCINE_PLOT]){
NSMutableArray *data = self.plotData[1];
NSString *str = [NSString stringWithFormat:@"%@",(data[index][@(fieldEnum)])];
return data[index][@(fieldEnum)];
}else if([plot.identifier isEqual:INTERVENTION_PLOT]){
NSMutableArray *data = self.plotData[2];
NSString *str = [NSString stringWithFormat:@"%@",(data[index][@(fieldEnum)])];
return data[index][@(fieldEnum)];
}else if ([plot.identifier isEqual:SMOKING_HABIT_PLOT]) {
NSMutableArray *data = self.plotData[3];
NSString *str = [NSString stringWithFormat:@"%@",(data[index][@(fieldEnum)])];
if ([str intValue]==0) {
return nil;
}
return data[index][@(fieldEnum)];
}else if ([plot.identifier isEqual:MENSTRUAL_PLOT]) {
NSMutableArray *data = self.plotData[4];
NSString *str = [NSString stringWithFormat:@"%@",(data[index][@(fieldEnum)])];
if ([str intValue]==0) {
return nil;
}
return data[index][@(fieldEnum)];
}else if ([plot.identifier isEqual:MENSTRUAL_TREATMENT_PLOT]) {
NSMutableArray *data = self.plotData[5];
NSString *str = [NSString stringWithFormat:@"%@",(data[index][@(fieldEnum)])];
if ([str intValue]==0) {
return nil;
}
return data[index][@(fieldEnum)];
}else if([plot.identifier isEqual:PSYCHOMOTOR_MILESTONE_PLOT]){
NSMutableArray *data = self.plotData[6];
NSString *str = [NSString stringWithFormat:@"%@",(data[index][@(fieldEnum)])];
return data[index][@(fieldEnum)];
}
return nil;
}
Hai trovato qualche soluzione? – Iducool
Finalmente ho trovato. Nel mio caso il mio controller di visualizzazione è nel controller di visualizzazione diapositive e la visualizzazione di diapositive ha un movimento panoramico. Quel gesto pan era in conflitto con scroll. Quindi, se qualcuno soffre di tali problemi, cerca gesti o gesti personalizzati. – Iducool