简体   繁体   中英

saving dynamic textfield value on click of button

There is CustomCell in tableviewcontroller .And in which there is dynamic txtfield. which is viewed by tag value. I am saving textfield value on dictionary on "textFieldShouldEndEditing". I want to save textfield value on button (Textfied is dynamic,no outlet is created for textfield). First Image attached

I want to edit the saved address. Second Image attached

kindly revert asap

If i understood your question properly then,

You need to set the button (Which i guess is also inside the custom cell), same tag as that of the indexpath of the cell. By that you can get the indexPath of the cell and get the cell by MyCustomCell *cell = [self.tableview cellForRowAtIndexPath:button.tag]

Then, you can get the textfield inside the cell also by just calling cell.textFieldName.text , and you will get the text.

For more clarity the IBAction method of the button, should be something like this.

 -(IBAction)buttonClickedToSaveTexd:(id)sender{

      UIButton *btnOfCertainCell = (UIButton*)sender;
      MyCustomCellClass *currentCell = [self.tableView cellForRowAtIndexPath:btnOfCertainCell.tag];
      NSString *textOfTheCell = currentCell.textFieldName.text;
 }

Again, for this to work, in cellForRowAtIndexPath you need to assign the button tag as indexPath.row . You dont need to set tag of the textfield.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM