Handling Text field In Table View

Save

Handling text field in table View is a way to manage text fields and prevent the text fields entered data while reloading the table.

When we use text fields in table view then text fields data will be removed when you reload the table.

So handle this issue we will use a model to save the text fields entered data.

And then pass the same model data in table view text fields.

And we are using textFieldDidEndEditing delegate to fetch the text filed data and save it in the model.

Handling text field in table View we will use the below steps.

1-> Create table view in controller

First, we will take a table view in the controller.

2-> Create cell for table view

Now we will create a cell for the table view. and the cell will contain two text fields.

3-> Create the model for saving text fields data

We have created the TextFieldModel model and in the model have two variable.

4-> Add the table view delegate

In the cell for a row, we have given a tag to identify the text fields in text fields delegates.

5-> Add text field delegate for fetch text field data

Here we are using did end editing delegate to save data in the model.

We used cell to identify the edited text fields with the index path of the cell.

-> Final code

This is the final view controller code for handling the text fields in the table view.

Now run the project and enter the data in text fields then reload the table with scrolling.

Then you will see your data will never loss and your code will work smoothly.

And thanks for reading this blog, for more blogs please click here.

So pls follow the above step and And if you have any issues or suggestions you can leave your message in the comment section I will try to solve this.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


2 comments

  • Sagar
    Hi Jitendra,
    I have data comes from service end and I need to update the field values and save it, please help.
    • jitendra kumar (Moderator)
      Hi,

      Please provide a screenshot of your issue.

      Thanks

  • css.php

    Webkul is a truly trusted and supported IT Company to develop business ideas for e-commerce. They provide professional support after deploying the solution to production and be responsible to act for fixing the reported issues or system errors. We highly encourage to deal with Webkul for business development.

    Hussein Zawia

    Hussein Zawia

    Co-founder, 24Dokan

    Talk to Sales

    Global

    Live Chat
    Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home