Answer the question
In order to leave comments, you need to log in
How to add cell to tableview?
Hello. I'm making a note app for ios.
I created an nsmutablearray array, threw a couple of objects into it for example.
Then I displayed all this in a tableview, everything works, it's normal.
Now the question itself.
The user must click on the button located on top of the entire tableview (to add a note), then a new cell should appear and a uitextfield should also appear in it (in order to give a name to the cell), then the keyboard appears and enter a note. Further, by pressing the Done button on the keyboard, the cell is saved.
To delete cells, I have a good method (deleted by swiping sideways).
I use a simple view controller (cells in the storyboard, I didn’t drag them from the object menu)
Please help.
Answer the question
In order to leave comments, you need to log in
As above and said.
After that, you create a UITextField directly in the cell (should be available to the whole class - in .m declare it a property), assign the current controller as the delegate of the text field. In the textFieldDidEndEditing method: do
cell.textLablel.text = self.textField.text;
[self.textField removeFromParent];
[tableView reloadData]
If I understood everything correctly, then something like this:
The code implies that there is either one section in the table, or a cell is added to the first of them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question