2012-02-15 73 views
0

很難讓CorePlot在我的項目中工作,但現在一切都運行了。除了空白的白屏,我只是沒有看到任何其他內容。ios coreplot設置

用下面的代碼,我不應該至少這樣一個空白圖嗎?

self.graph = [[[CPTXYGraph alloc] initWithFrame:frame] autorelease]; 
layerHostingView.hostedGraph = graph; 

[self addSubview:layerHostingView]; 

感謝幫助我這。

FYI這不是我的第一次測試coreplot。這幾天我一直在旋轉我的車輪,並且嘗試了每一個我可以得到的完整例子。我認爲從基礎開始重新開始是個好主意。

回答

0

所不同的是,你在你的答案發布的代碼,您創建了一個CPTGraphHostingView並添加它作爲RaceDetailView的子視圖。在你的問題的代碼中,我懷疑託管視圖是零。我不認爲添加主題會有所作爲 - 默認外觀是帶有黑色線條和標籤的簡單白色背景,您仍然可以看到某些內容。

+0

我真的不知道真正的答案,我太無興趣弄清楚它是什麼。不過,我覺得給你答案比給我更好。知道你會從中得到更多的分數是更大的好處! – Jacksonkr 2012-02-18 22:44:30

3

我真的不知道什麼改變了,但我看到一個赤裸圖與此代碼。

.H

#import <UIKit/UIKit.h> 
#import "CorePlot-CocoaTouch.h" 

@interface RaceDetailView : UIView <CPTPlotSpaceDelegate, CPTPlotDataSource, CPTScatterPlotDelegate> 

@end 

.M

#import "RaceDetailView.h" 

@implementation RaceDetailView 

- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     CGRect f = self.frame; 
     CPTXYGraph *graph = [[[CPTXYGraph alloc] initWithFrame:f] autorelease]; 
     CPTGraphHostingView *layerHostingView = [[CPTGraphHostingView alloc] initWithFrame:f]; 
     layerHostingView.hostedGraph = graph; 
     [graph applyTheme:[CPTTheme themeNamed:kCPTDarkGradientTheme]]; 

     [self addSubview:layerHostingView]; 
    } 
    return self; 
} 

@end 
+1

哇,老兄,我有同樣的問題,應用主題工作! – JomanJi 2013-09-27 14:53:41