ios - Get indexPath for the customtableview textfield -


i have textfield in mycustomcell, , set textfield delegate in cellforrowindexpath tableview delegate. when user changes textfield value , calls textfieldshouldendediting. works.

however, wonder how know textfield (indexpath) changed?

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cell";      mycustomcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];      if (cell == nil)      {           // use if created cell ib         cell = [[[nsbundle mainbundle] loadnibnamed:@"mycustomcell" owner:self options:nil] objectatindex:0];             // otherwise use           cell = [[[mycustomcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease];            // set view controller text field delegate           cell.textfield.delegate = self;     }      // configure cell...      return cell; }  - (bool)textfieldshouldendediting:(uitextfield *)textfield {     [textfield resignfirstresponder];     return yes; } 

set uitextfield tag in cellforrowatindexpath method. if there 1 section in tableview can set row tag. this.

cell.textfield.delegate = self; cell.textfield.tag = indexpath.row; 

and in textfieldshouldendediting method can check tag.

- (bool)textfieldshouldendediting:(uitextfield *)textfield {     int row = textfield.tag;      [textfield resignfirstresponder];     return yes; } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -