ios - Reference view controller from custom UITableViewCell class -
i have class called magradecell
that's custom uitableviewcell
class. before had class , setting cell inside view controller (macontroller
), configureheadercell
'd self
(which resolved viewcontroller.
now have custom class uitableviewcell
, can't refer viewcontroller self
. mean should alloc
, init
new viewcontroller? or have super
or import viewcontroller , interface property or something?
try this,
in magradecell.h
typedef void (^yourcallback)(magradecell *cell); //you may or may not use cell parameter according need
create property
@property (readwrite, copy) yourcallback callback;
in magradecell.m
- (void)someaction { if (self.callback != nil) { self.callback(self); } }
in cell configuration method
magradecell *cell = .... ..... cell.callback = ^(magradecell *gradecell) { //do stuff };
Comments
Post a Comment