简体   繁体   English

ios coreplot设置

[英]ios coreplot setup

It was difficult to get CorePlot to work in my project, but everything runs now. CorePlot在我的项目中工作很难,但是现在一切都可以运行了。 I just don't see ANYTHING other than a blank white screen. 除了空白的白色屏幕,我什么都看不到。

With the following code, shouldn't I at least so a blank graph? 使用以下代码,我至少应该不应该这样一个空白图吗?

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

[self addSubview:layerHostingView];

Thanks for helping me with this. 感谢您协助

FYI this is not my first test with coreplot . 仅供参考,这不是我第一次使用coreplot测试。 I've been spinning my wheels on this for days and have since tried every full example I can get my hands on. 我已经为此花了几天的时间,从那以后,我尝试了所有可以使我动手的完整示例。 I figured it's a good idea to start over again with the basics. 我认为从基础知识重新开始是个好主意。

I honestly have no idea what changed, but I see a naked graph with this code. 老实说,我不知道发生了什么变化,但是我看到了带有此代码的图。

.h 。H

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

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

@end

.m .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

The difference is in the code you posted in your answer, you created a CPTGraphHostingView and added it as a subview of the RaceDetailView . 区别在于您在答案中发布的代码,创建了CPTGraphHostingView并将其添加为RaceDetailView的子视图。 In the code in your question, I suspect the hosting view was nil. 在您问题中的代码中,我怀疑托管视图为nil。 I don't think adding the theme would make a difference--the default appearance is a simple white background with black lines and labels and you'd still be able to see something. 我认为添加主题不会有所不同-默认外观是带有黑线和标签的简单白色背景,您仍然可以看到一些内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM