Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 核心图在x轴上显示错误的日期_Ios_Objective C_Ios7_Core Plot - Fatal编程技术网

Ios 核心图在x轴上显示错误的日期

Ios 核心图在x轴上显示错误的日期,ios,objective-c,ios7,core-plot,Ios,Objective C,Ios7,Core Plot,我对在x轴上显示日期范围有问题。此范围包含作为时间戳值的日期:1398172101、1398176156、1398181026、1398196536等。下面的代码显示了如何将日期格式化为人类可读的 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"hh:mm dd/MM/yy"]; CPTTimeFormatter *timeFormatter =

我对在x轴上显示日期范围有问题。此范围包含作为时间戳值的日期:1398172101、1398176156、1398181026、1398196536等。下面的代码显示了如何将日期格式化为人类可读的

 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
 [dateFormatter setDateFormat:@"hh:mm dd/MM/yy"];
 CPTTimeFormatter *timeFormatter = [[CPTTimeFormatter alloc] initWithDateFormatter:dateFormatter];
 timeFormatter.referenceDate = [NSDate dateWithTimeIntervalSince1970:0.0];
 x.labelFormatter = timeFormatter;
我不确定是否为
timeFormatter.referenceDate
设置了正确的值。我在stackoverflow上发现了一个描述相同问题的问题,但正确的答案对我来说并不适用。它告诉您将
[nsdatedatewithtimeintervalencesince1970:0.0]
分配到
时间格式。referenceDate


我犯了什么错?谢谢

确保打印空间的
xRange
设置正确。例如,要创建一个包含问题中列出的值的范围,请执行以下操作:

NSTimeInterval minTime = 1398172101;
NSTimeInterval maxTime = 1398196536;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(minTime)
                                                length:CPTDecimalFromDouble(maxTime - minTime)];

时间戳的零点是多少?您已将其设置为1970年1月1日。@EricSkroch我的每个时间戳值都是使用[[NSDate date]timeIntervalSince1970]生成的。核心绘图代码看起来正常。有什么问题?你有没有收到格式错误的标签?与正确日期和时间的偏移量?标签上的日期格式正确。问题是日期错误,例如:03:00 03/01/70。看看年份:2070年,时间和其他日期也是错误的,你是对的。xRange属性的值错误。你的代码工作得很好。谢谢