我有一个 iOS7 应用程序,我正在尝试将 CorePlot 1.4 集成到(依赖项目安装)中。
@property (nonatomic) CPTGraphHostingView *hostingView;
和
_hostingView = [[CPTGraphHostingView alloc] initWithFrame:CGRectNull];
(_hostingView
受自动布局的影响。)如果我再添加一个图表:
CPTXYGraph *graph = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
_hostingView.hostedGraph = graph;
我首先得到这个例外:
-[CPTTextStyle attributes]: unrecognized selector sent to instance 0xa392900
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CPTTextStyle attributes]: unrecognized selector sent to instance 0xa392900'
5 myapp 0x00074325 -[CPTAxis updateAxisLabelsAtLocations:inRange:useMajorAxisLabels:] + 1141
6 myapp 0x00075662 -[CPTAxis relabel] + 1202
绝望中,我updateAxisLabelsAtLocations:inRange:useMajorAxisLabels
通过以下方式解决了这个问题:
NSDictionary *textAttributes = nil;
BOOL hasAttributedFormatter = FALSE;
然后得到下一个异常:
-[__NSCFString sizeWithTextStyle:]: unrecognized selector sent to instance 0x9591e90
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString sizeWithTextStyle:]: unrecognized selector sent to instance 0x9591e90'
5 myapp 0x00081520 -[CPTTextLayer sizeThatFits] + 320
6 myapp 0x0008163c -[CPTTextLayer sizeToFit] + 108
7 myapp 0x00080559 -[CPTTextLayer initWithText:style:] + 313
8 myapp 0x00074b87 -[CPTAxis updateAxisLabelsAtLocations:inRange:useMajorAxisLabels:] + 3159
9 myapp 0x00075672 -[CPTAxis relabel] + 1202
然后我通过在以下代码中注释掉这一行来“修复”这个问题sizeThatFits
:
else {
// textSize = [myText sizeWithTextStyle:self.textStyle];
}
下一个例外是:
-[__NSCFString drawInRect:withTextStyle:inContext:]: unrecognized selector sent to instance 0xa162bd0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString drawInRect:withTextStyle:inContext:]: unrecognized selector sent to instance 0xa162bd0'
5 myapp 0x00081dc8 -[CPTTextLayer renderAsVectorInContext:] + 1144
6 myapp 0x00063f60 -[CPTLayer drawInContext:] + 112
这是通过在以下代码中注释掉来修复的renderAsVectorInContext
:
else {
// [myText drawInRect:newBounds
// withTextStyle:self.textStyle
// inContext:context];
}
现在终于没有抛出异常并显示图形边界。但是,如果我随后开始添加数据/图例等,则会引发新的异常:(
轴上没有显示文本等。当然这是因为我已经注释掉了代码。但是任何线索为什么会抛出这些异常?我很绝望;S
似乎我错过了集成中的一些基本内容。但我的集成(虽然是 CorePlot 1.3)前段时间在 Xcode4 上的 iOS6 应用程序中运行良好。