2014-02-06 72 views
2

使用coreplot庫處理折線圖。它引發無效參數異常。 我已經完成了septate項目並創建了xib文件,並且已經將該xib文件與CPDScatterPlotViewController連接起來。它運行和工作,但是當我嘗試與我的項目集成時,它會拋出異常。 使用此代碼:NSInvalidArgumentException',原因:' - [__ NSCFConstantString sizeWithTextStyle:]:發送到實例的無法識別的選擇器0x170838

#import "CPDScatterPlotViewController.h" 

@implementation CPDScatterPlotViewController 

@synthesize hostView = hostView_; 

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

-(void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 
    // Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - UIViewController lifecycle methods 
-(void)viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 
    [self initPlot]; 
} 

#pragma mark - Chart behavior 
-(void)initPlot { 
    [self configureHost]; 
    [self configureGraph]; 
    [self configurePlots]; 
    [self configureAxes];  
} 

-(void)configureHost { 
    self.hostView = [(CPTGraphHostingView *) [CPTGraphHostingView alloc] initWithFrame:self.view.bounds]; 
    self.hostView.allowPinchScaling = YES;  
    [self.view addSubview:self.hostView];  
} 

錯誤是在調試上CPTMutableTextStyle發生。

-(void)configureGraph { 
     // 1 - Create the graph 
     CPTGraph *graph = [[CPTXYGraph alloc] initWithFrame:self.hostView.bounds]; 
     [graph applyTheme:[CPTTheme themeNamed:kCPTDarkGradientTheme]]; 
     self.hostView.hostedGraph = graph; 
     // 2 - Set graph title 
     NSString *title = @"Portfolio Prices: April 2012"; 
     graph.title = title; 
     // 3 - Create and set text style 
     CPTMutableTextStyle *titleStyle = [CPTMutableTextStyle textStyle]; 
     titleStyle.color = [CPTColor whiteColor]; 
     titleStyle.fontName = @"Helvetica-Bold"; 
     titleStyle.fontSize = 16.0f; 
     graph.titleTextStyle = titleStyle; 
     graph.titlePlotAreaFrameAnchor = CPTRectAnchorTop; 
     graph.titleDisplacement = CGPointMake(0.0f, 10.0f); 
     // 4 - Set padding for plot area 
     [graph.plotAreaFrame setPaddingLeft:30.0f];  
     [graph.plotAreaFrame setPaddingBottom:30.0f]; 
     // 5 - Enable user interactions for plot space 
     CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace; 
     plotSpace.allowsUserInteraction = YES; 
    } 


    @end 
+0

它會崩潰哪行? – trojanfoe

+0

對不起,在這一行:graph.title = title; –

回答

相關問題