B
B
Bullstreak2014-08-19 17:17:38
Objective-C
Bullstreak, 2014-08-19 17:17:38

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

3 answer(s)
F
Flie, 2014-08-21
@Flie

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]

Should earn. If not, you need to raise your hands to the sky with a sharp movement and say "Damn it, why doesn't it work?" - always helps me.

C
Cassar, 2014-08-21
@Cassar

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.

V
Vanya Ivanov, 2015-01-04
@mr_cloud

https://vk.com/videos-58860049?z=video-58860049_16...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question