ios - Having a UIButton be tapped in a UICollectionViewCell -
i have uicollectionview cells laid out.
i have declared subview:
@property (nonatomic, strong) uibutton *abutton;
i have declared in each cell so:
if (_abutton == nil) { _abutton = [uibutton buttonwithtype:uibuttontypesystem]; } // add in _abutton info here [self.contentview addsubview:_abutton]; // call button pressed button [_abutton addtarget:self action:@selector(abuttonpressed:) forcontrolevents:uicontroleventtouchupinside];
the button click method so:
- (ibaction) abuttonpressed:(uibutton *) sender { // code never gets heree }
the if(_abutton
== `nil) needed since cells reused.
how make work now? thanks.
add button action code before button added view.... may work .
// call button pressed button [_abutton addtarget:self action:@selector(abuttonpressed:) forcontrolevents:uicontroleventtouchupinside]; // add in _abutton info here [self.contentview addsubview:_abutton];
Comments
Post a Comment