i have uitextfield in customcell. want able text user inputs in it. in customcell.m file can text inputed
[self.atextfield addtarget:self action:@selector(atextfieldediting:) forcontrolevents:uicontroleventeditingchanged]; but cannot indexpath can save nsmutablearray holds uitextfields.
in tableview cannot didselectrowatindexpath run. cannot textfielddidbeginediting method output anything. if helps have tableview sections.
my idea @ moment indexpath.row , indexpath.section tableview , save them extern can access in customcell.m
i grateful ideas or specific examples of how this. or different cleaner way accomplish want.
you should able index path using -indexpathforrowatpoint: method on uitableview.
you can (not tested):
- (void)atextfieldediting:(uitextfield *)textfield { cgpoint convertedpoint = [textfield.superview convertpoint:textfield.center toview:self.tableview]; nsindexpath *indexpath = [self.tableview indexpathforrowatpoint:convertedpoint]; // use index path... } edit:
in case cell receiving edit events, can define protocol , make view controller delegate of cell. call delegate method atextfieldediting method , pass cell. have cell can call -indexpathforcell on table view. if none of makes sense, delegate pattern. it's common in cocoa/cocoa touch , documented online.
Comments
Post a Comment