objective c - How to pass touch event to a pie chart -
i new core plot framework , facing issue:
i cpgraphhostigview draw pie chart. cpgraphhostigview
doesn't detect touch events have uiview
on can detect touches. how can pass touch events pie chart cppiechartdelegate
method.
- (void)piechart:(cppiechart *)plot slicewasselectedatrecordindex:(nsuinteger)index
gets invoked.
any appreciated. in advance.
-ravi
cpgraphhostingview
inherits uiview
, inherits uiresponder
. therefore, cpgraphhostingview
does detect touch events.
here steps should follow in order detect touch events on pie chart slices :
- add
cpgraphhostingview
view in interface builder. can achieve adding simpleuiview
, change class manuallycpgraphhostingview
; declare hosting view in code:
// in view controller .h file: ... cpgraphhostingview *graphhosting; } @property (nonatomic, retain) iboutlet cpgraphhostingview *graphhosting; // in view controller .h file: @synthesize graphhosting;
make connection iboutlet in interface builder;
initialize graph , link graph hosting view:
self.graph = [[cpxygraph alloc] initwithframe: self.graphhosting.bounds]; self.graphhosting.hostedgraph = self.graph;
initialize pie chart , set view controller delegate:
cppiechart *piechart = [[cppiechart alloc] init]; piechart.delegate = self; ... [self.graph addplot:piechart] [piechart release];
add
<cppiechartdelegate>
view controller's declaration, , implement method:- (void)piechart:(cppiechart *)plot slicewasselectedatrecordindex:(nsuinteger)index
Comments
Post a Comment