ios coreplot设置

时间:2012-02-15 16:28:16

标签: ios core-plot

很难让CorePlot在我的项目中工作,但现在一切都在运行。除了空白的白色屏幕外,我什么都看不到。

使用以下代码,我不应该至少这样一个空白图表吗?

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

[self addSubview:layerHostingView];

感谢 帮助我。

FYI 这不是我对coreplot的第一次测试。这几天我一直在旋转我的轮子,从那以后我尝试了每一个完整的例子。我认为从基础开始重新开始是一个好主意。

2 个答案:

答案 0 :(得分: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 :(得分:0)

区别在于您在答案中发布的代码,您创建了CPTGraphHostingView并将其添加为RaceDetailView的子视图。在你的问题的代码中,我怀疑托管视图是零。我不认为添加主题会产生影响 - 默认外观是一个简单的白色背景,黑色线条和标签,你仍然可以看到一些东西。