基本上,我在使用Core Plot时遇到了崩溃。根据关于如何安装CorePlot
静态库的tutorial,我只需将CorePlotHeaders
文件和libCorePlot-CocoaTouch.a
拖到我的项目中即可。然后我添加QuartzCore
和Accelerate框架。然后我将“Other Linker Flags”更改为“-Objc”和“-all_load”。
我写了这段代码:
- (void) configLineGraph
{
CGRect graphFrame = CGRectMake(0, 0, self.graphView.frame.size.width, self.graphView.frame.size.height);
// The graph should be put into a hosting view
CPTGraphHostingView *hostingView = [[CPTGraphHostingView alloc]init];
[hostingView setFrame:graphFrame];
// Add it to the view
[self.graphView addSubview:hostingView];
// Draw with CPTGraph
// This is a line graph
CPTXYGraph *graph = [[CPTXYGraph alloc]init];
[graph setFrame:hostingView.frame];
// Add the graph to the hosting view
[hostingView setHostedGraph:graph];
// Draw the scatter plot
CPTScatterPlot *scatterPlot = [[CPTScatterPlot alloc]init];
[scatterPlot setFrame:graph.bounds];
// Add the scatter plot to graph
[graph addPlot:scatterPlot];
[scatterPlot setDataSource:self];
// Setup the plot space
// Location is the initial value
// Length is the range
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) scatterPlot.plotSpace;
[plotSpace setXRange:[CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat([voltageDataArray count] - 1)]];
[plotSpace setYRange:[CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(1.55)]];
}
然而,当我运行我的项目时,它崩溃了消息:
2015-07-02 16:59:44.435 Ansmann[4952:236111] -[CPTTextStyle attributes]: unrecognized selector sent to instance 0x7f97a1e26a90
2015-07-02 16:59:44.439 Ansmann[4952:236111] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CPTTextStyle attributes]: unrecognized selector sent to instance 0x7f97a1e26a90'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ac8dc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010a56abb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010ac950ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010abeb13c ___forwarding___ + 988
4 CoreFoundation 0x000000010abeacd8 _CF_forwarding_prep_0 + 120
5 Ansmann 0x0000000109ce7d7b -[CPTAxis updateAxisLabelsAtLocations:inRange:useMajorAxisLabels:] + 1259
6 Ansmann 0x0000000109ce93b1 -[CPTAxis relabel] + 1457
7 Ansmann 0x0000000109ceac7b -[CPTAxis layoutSublayers] + 75
8 QuartzCore 0x0000000109f536d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
9 QuartzCore 0x0000000109f53546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
10 QuartzCore 0x0000000109ebf886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
11 QuartzCore 0x0000000109ec0a3a _ZN2CA11Transaction6commitEv + 462
12 UIKit 0x000000010b2c6a2d -[UIApplication _reportMainSceneUpdateFinished:] + 44
13 UIKit 0x000000010b2c76f1 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2648
14 UIKit 0x000000010b2c60d5 -[UIApplication workspaceDidEndTransaction:] + 179
15 FrontBoardServices 0x00000001101bf5e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
16 CoreFoundation 0x000000010abc141c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
17 CoreFoundation 0x000000010abb7165 __CFRunLoopDoBlocks + 341
18 CoreFoundation 0x000000010abb6f25 __CFRunLoopRun + 2389
19 CoreFoundation 0x000000010abb6366 CFRunLoopRunSpecific + 470
20 UIKit 0x000000010b2c5b42 -[UIApplication _run] + 413
21 UIKit 0x000000010b2c8900 UIApplicationMain + 1282
22 Ansmann 0x0000000109c95e7f main + 111
23 libdyld.dylib 0x000000010cdda145 start + 1
24 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
答案 0 :(得分:0)
要安装CorePlot,您可以使用cocoapods
只需将行广告连播'CorePlot'添加到Podfile并运行pod install。
另外,请添加用于设置数组“voltageDataArray”的代码以及用于“graphView”的类?
答案 1 :(得分:0)
链接器标志应为-ObjC
和-all_load
(注意大写字母“C”)。