xcode - Detect a button from a custom cell and change the properties -
i have table there button custom cell. when press button, calls method detects button using code:
nsindexpath *indexpath = [nsindexpath indexpathforrow: [[[notification userinfo] valueforkey:@"row"] intvalue] insection: 0]; placeroomcustomcell *cell = (placeroomcustomcell*)[self tableview:self.tableview cellforrowatindexpath:indexpath]; (uiview *view in cell.contentview.subviews){ if (view.tag == 1) { (uiview *subview in view.subviews){ if ([subview iskindofclass:[uibutton class]]){ [(uibutton *)subview setimage:[uiimage imagenamed:@"placeroomtablecelllikebuttonredicon.png"] forstate:uicontrolstatenormal]; [(uibutton *)subview setimage:[uiimage imagenamed:@"placeroomtablecelllikebuttonredicon.png"] forstate:uicontrolstatehighlighted]; [(uibutton *)subview setimage:[uiimage imagenamed:@"placeroomtablecelllikebuttonredicon.png"] forstate:uicontrolstatedisabled]; nslog(@"tag %i",subview.tag); //correct } } } }
the tag correct, image not changed.
i can't use id sender of button directly, or rather, prefer not use it.
the code seems correct
thank you!
normally, when ui object sends action controller, method passed sender
, can not use this?
e.g. definition of method code above sits might like:
-(void)buttonpressed:(id)sender;
where sender
should button. although have sneaky suspicion we're missing other vital information in question, since you're using nsnotifications...
Comments
Post a Comment