iOS核心打印滚动条不显示';工作不好
使用CorePlot版本1.6。 运行iOS 8.3 我用核心图和散点图来表示多重线。 当我滚动时,图形移动到跳跃,并锁定。我不知道会发生什么。你能帮助我吗? 这是我的代码:iOS核心打印滚动条不显示';工作不好,ios,core-plot,Ios,Core Plot,使用CorePlot版本1.6。 运行iOS 8.3 我用核心图和散点图来表示多重线。 当我滚动时,图形移动到跳跃,并锁定。我不知道会发生什么。你能帮助我吗? 这是我的代码: #import <UIKit/UIKit.h> #import "CorePlot-CocoaTouch.h" @interface TemporalLineViewController:UIViewController<CPTPlotDataSource, CPTScatterPlotDelegate&
#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;
}
#导入
#导入“CorePlot CoCoCoTouch.h”
@接口临时视图控制器:UIViewController
@属性(强,非原子)IBMOutlet CPTGraphHostingView*hostingView;
@结束
@接口临时虚拟控制器(){
NSMutableDictionary*日期;
}
@属性(非原子、读写、强)NSArray*plotData;
@结束
@临时虚拟控制器的实现
-(CPTGraph*)createGraph{
initWithFrame:CGRectMake(viewGraph.frame.origin.x,viewGraph.frame.origin.y,500,viewGraph.frame.size.height)];
CPTGraph*graph=[[CPTXYGraph alloc]initWithFrame:hostingView.bounds];
[图形应用程序主题:[CPT主题:kCPTSlateTheme]];
hostingView.hostedGraph=图形;
//斧头
CPTXYAxisSet*axisSet=(CPTXYAxisSet*)graph.axisSet;
CPTXYAxis*x=axisSet.xAxis;
x、 majorIntervalLength=CPTDecimalFromDouble(一天);
x、 正交坐标CIMAL=CPTDecimalFromDouble(0.0);
x、 minorTicksPerInterval=0;
NSDateFormatter*dateFormatter=[[NSDateFormatter alloc]init];
[日期格式化程序setDateFormat:@“dd/MM/yyyy”];
CPTTimeFormatter*timeFormatter=[[CPTTimeFormatter alloc]initWithDateFormatter:dateFormatter];
timeFormatter.referenceDate=[[NSDate alloc]init];
x、 labelFormatter=时间格式化程序;
x、 labelRotation=CPTFloat(M_PI_4);
CPTXYAxis*y=axisSet.yAxis;
y、 隐藏=是;
y、 正交坐标CIMAL=CPTDecimalFromInt(0);
返回图;
}
-(无效)创建散点图{
CPTGraph*图形=[self createGraph];
CPTXYPlotSpace*plotSpace=(CPTXYPlotSpace*)graph.defaultPlotSpace;
NSTimeInterval xLow=0.0;
plotSpace.xRange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(xLow)长度:CPTDecimalFromDouble(一天*10.0)];
plotSpace.yRange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(-1)长度:CPTDecimalFromDouble(5.0)];
plotSpace.allowUserInteraction=是;
plotSpace.allowsMomentum=是;
CPTSatterPlot*diagnosticPlot=[self CreateScatterPlot With Identifier:DIAGNOSTIC_PLOT With LineColor:[CPTColor greenColor]With FillColor:[CPTColor greenColor]];
CPTSatterPlot*vaccinePlot=[self createScatterPlotWithIdentifier:VACCINE_PLOT withLineColor:[CPTColor blackColor]withFillColor:[CPTColor blackColor]];
CPTSatterPlot*InterferencePlot=[self-createScatterPlotWithIdentifier:Interference_PLOT withLineColor:[CPTColor blueColor]withFillColor:[CPTColor blueColor]];
CPTSatterPlot*smokingHabitPlot=[带有标识符的自创散点图:吸烟习惯\u带有lineColor:[CPTColor yellowColor]和fillColor:[CPTColor yellowColor]]的绘图;
CPTSatterPlot*MemenalPlot=[self createScatterPlotWithIdentifier:Memenal_PLOT withLineColor:[CPTColor redColor]withFillColor:[CPTColor redColor]];
CPTSatterPlot*MenalTreatmentPlot=[self-createdScatterPlot with Identifier:Menal_TREATMENT_PLOT with LineColor:[CPTColor orangeColor]with FillColor:[CPTColor orangeColor]];
CPTSatterPlot*psychomotorMilestonePlot=[self-createdScatterPlot with Identifier:PSYCHOMOTOR_MILESTONE_PLOT with LineColor:[CPTColor purpleColor]with FillColor:[CPTColor purpleColor]];
[graph addPlot:vaccinePlot toPlotSpace:plotSpace];
[graph addPlot:diagnosticPlot toPlotSpace:plotSpace];
[graph addPlot:InterferencePlot-toPlotSpace:plotSpace];
[graph addPlot:smokingHabitPlot toPlotSpace:plotSpace];
[graph addPlot:PermenalPlot toPlotSpace:plotSpace];
[graph addPlot:MenalTreatmentPlot-toPlotSpace:plotSpace];
[graph addPlot:psychomotorMilestonePlot toPlotSpace:plotSpace];
}
-(CPTSatterPlot*)创建带标识符的散点图:(NSString*)带lineColor的标识符:(CPTColor*)带fillColor的lineColor:(CPTColor*)fillColor{
CPTSatterPlot*数据源线性图=[[CPTSatterPlot alloc]init];
dataSourceLinePlot.identifier=标识符;
CPTMutableLineStyle*lineStyle=[dataSourceLinePlot.dataLineStyle mutableCopy];
lineStyle.lineWidth=3.0;
lineStyle.lineColor=lineColor;
dataSourceLinePlot.dataLineStyle=线型;
CPTPlotSymbol*plotSymbol2=[CPTPlotSymbol ellipsePlotSymbol];
plotSymbol2.fill=[CPTFill fillWithColor:fillColor];
plotSymbol2.size=CGSizeMake(10.0,10.0);
dataSourceLinePlot.plotSymbol=plotSymbol2;
返回数据源线性图;
}
-(无效)生成数据{
NSMutableArray*数据=[NSMutableArray];
[data addObject:[self-createDiagnosticData]];
[data addObject:[self-createVaccineData]];
[data addObject:[self-createInterventionData]];
[data addObject:[self-createSmokingHabitData]];
[数据添加对象:[自行创建月经数据]];
[数据添加对象:[自创建月经治疗数据];
[data addObject:[self-CreateMilestoneData];
self.plotData=数据;
}
#布拉格标记-
#pragma标记图数据源方法
-(NSUInteger)numberOfRecordsForPlot:(CPTPlot*)绘图
{
NSLog(@“numberOfRecordsForPlot”);
if([plot.identifier isEqual:诊断图]){
NSMUTABLEARRY*data=self.plotData[0];
返回数据.count;
}else if([plot.identifier isEqual:VACCINE\u plot]){
NSMutableArray*data=self.plotData[1];
返回数据.count;
}else if([plot.identifier isEqual:INTERVENTION\u plot]){
NSMutableArray*data=self.plotData[2];
返回数据.count;
}else if([plot.identifier isEqual:吸烟习惯\u plot]){
NSMutableArray*data=self.plotData[3];
返回数据.count;
}else if([plot.identifier isEqual:月经曲线图]){
NSMutableArray*data=self.plotData[4];
返回数据.count;
}如果([plot.identifier isEqual:月经治疗