2011-06-21 24 views
0

我想在CPXYPlotSpace上的x軸上顯示數據。我已經看到使用類似的東西在mac上這樣做,但它不適用於iphone,所以任何建議或我必須手動執行。使用核心圖的x軸iphone上的日期

NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; 
dateFormatter.dateStyle = kCFDateFormatterShortStyle; 
CPTimeFormatter *timeFormatter = [[[CPTimeFormatter alloc] initWithDateFormatter:dateFormatter] autorelease]; 
timeFormatter.referenceDate = refDate; 
x.labelFormatter = timeFormatter; 

回答

0

不要忘記設置intervalLength

NSTimeInterval oneDay = 24 * 60 * 60; 
x.majorIntervalLength = CPDecimalFromFloat(oneDay); 
y.orthogonalCoordinateDecimal = CPDecimalFromFloat(oneDay); 
+0

我使用'NSTimeInterval。一天= 24 * 60 * 60; (0「20/6/2011」)長度:CPDecimalFromFloat(oneDay * 5.0f)];' – time