添加 CPTGraphHostingView 作为子视图

发布于 2024-11-30 04:58:03 字数 357 浏览 0 评论 0原文

关于此的问题并不多,而且没有一个能够以可以解决我的问题的方式得到回答,如果我问的是已经被问过的问题,仍然很抱歉。

我的问题是我想使用核心图在视图内绘制图表。因此,我在 appviewcontroller.xib 中添加了 IB 上的视图,但随后我找不到如何将我刚刚在 IB 上定义的特定区域链接到文件的所有者。

一点精确:我设法在另一个应用程序中使用核心图,当时它是主视图,但现在我想将它添加到现有应用程序中,因此现有视图不起作用......

并且添加新区域后,我刚刚进入 IB,并将对象库中的视图拖到我的 appviewcontroller.xib 上。

那么如何将该特定视图链接到我为其编写的代码呢?

感谢您的帮助!

There isn't a lot of questions about this and none of them were answered in a way that could solve my problem, still sorry if I'm asking something that was asked already.

My problem is that I'd like to use core plot to draw a graph inside a view. So I add the view on IB in my appviewcontroller.xib , but thenI can't find how to link that specific zone I just defined on IB to the file's owner.

A bit of precision: I managed to use core plot in another application, when it was the main view, but now that I want to add it to an existing application, so an existing view, it doesn't work...

And to add the new zone, I just went into IB, and dragged a view from the objects library onto my appviewcontroller.xib.

So how do I link that particular view to the code I wrote for it ?

Thanks for any help !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

书间行客 2024-12-07 04:58:03

您必须将创建的 uiview 添加到 self.view,然后向其中添加图形托管视图...
试试这个

- (void)loadView {
 self.view =view1;    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    CPGraphHostingView *hostingView = [[CPGraphHostingView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
    hostingView.backgroundColor=[UIColor whiteColor];
    graph = [[CPXYGraph alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];   

    hostingView.hostedGraph = graph;
    [view1 addSubview:hostingView];

U have to add uiview created to self.view,then add graph hosting view to it...
Try this

- (void)loadView {
 self.view =view1;    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    CPGraphHostingView *hostingView = [[CPGraphHostingView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
    hostingView.backgroundColor=[UIColor whiteColor];
    graph = [[CPXYGraph alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];   

    hostingView.hostedGraph = graph;
    [view1 addSubview:hostingView];
倦话 2024-12-07 04:58:03

在故事板(xib 文件)的主视图(默认视图为视图)中创建另一个视图(视图 2),并确保它(视图 2)作为头文件(.h)中的出口。

将其拖动并连接到故事板(xib 文件)中新创建的视图,因此在故事板中进行必要的连接后,故事板应如下所示:

View---view (默认视图连接到视图)和
视图2---视图(新视图,视图2连接到它的视图)。

在实现文件的loadView方法中,尝试一下这些代码

-(void)loadView {
    [super loadView];

    newView = [[CPTGraphHostingView alloc] initWithFrame: [[UIScreen       mainScreen]applicationFrame]];

    [self.view2 addSubview:newView];

}

Create another view(view 2) in a main view(default view let it be view)in the storyboard(xib file) and make sure it (view 2) as outlet in the header file(.h).

Drag and Connect it to the newly created view in the storyboard(xib file) so after making necessary connections in the storyboard,storyboard should be like this:

View---view (default view connected to view) and
view 2---view (new view, view 2 connected to its view).

In the loadView method of implementation file,try out these code

-(void)loadView {
    [super loadView];

    newView = [[CPTGraphHostingView alloc] initWithFrame: [[UIScreen       mainScreen]applicationFrame]];

    [self.view2 addSubview:newView];

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文