0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Core plotで-[UIView setHostedLayer:]: unrecognized selector sent to instanceエラー

0
Last updated at Posted at 2012-05-19

どこでエラーになってるのかはデバッガーを見ればスグにわかるが

    CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;
	hostingView.collapsesLayers = NO; // Setting to YES reduces GPU memory usage, but can slow drawing/scrolling
	hostingView.hostedGraph = graph;

という感じで、hostingViewをいじってる所で落ちているのがわかる。

hostingView.collapsesLayers = NO;

そもそも、下のようにCastするにはself.viewのClassがCPTGraphHostingViewであることが前提のコードなってる。

Xibのview

CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;

なので、XibでViewを作ってるなら、CPTGraphHostingViewをClassに適応するか普通にCPTGraphHostingViewのインスタンスをViewとして使うように変更すればよい。

    CPTGraphHostingView *hostingView = [[[CPTGraphHostingView alloc] init] autorelease];
	hostingView.collapsesLayers = NO; // Setting to YES reduces GPU memory usage, but can slow drawing/scrolling
	hostingView.hostedGraph = graph;
    [self setView:hostingView];// self.viewをhostingViewにする

これでタイトルのエラーは出なくなる。

0
1
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?