iphone - How to use an IBOutlet from parent class? -
i'm working on ios , having trouble accessing iboutlet parent class, in case label life of character.
my viewcontroller (parent) this:
@interface opponentviewcontroller : uiviewcontroller { iboutlet uilabel *opponent_life; iboutlet opponentview *opponentview; } @end
the opponentview (child) class character (image) reside , player touch interaction. when player touch opponentview label should refreshed.
- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { }
thanks.
if i'm understanding question correctly update opponent_life
when ever detect touch in opponentview
. here 2 ways of assigning label view can used tocuhesbegan:withevent:
1. assigning label view in ib
@interface opponentview : uiview { iboutlet uilabel *opponent_life; }
in nib file opponentviewcontroller
change type of view uiview
opponentview
, connect label outlet of view.
2. assigning label in viewdidload
@interface opponentview : uiview { uilabel *opponent_life; } @property (nonatomic, retain) uilabel *opponent_life;
in `opponentviewcontroller'
- (void)viewdidload { [super viewdidload]; opponentview.opponent_life = opponent_life; }
Comments
Post a Comment