0
votes

I have a UITableView containing UITextFields. I would like to be able to add new text fields by pasting text copied from another application and have the paste event create as many textFields as there are newlines in the pasted text.

For example, I have selected these lines from the Notes app:

   Alice
   Fred
   Betsy

When I paste that selection into my app via the keyboard when editing a textField I get the string "Alice Fred Betsy" with the newline characters removed. This removal must be happening deep in the keyboard before it gets to the textField. Is there some way I can intervene and make the paste into three paste events resulting in three textFields?

Thanks!

-Allan

1

1 Answers

1
votes

Since UITextField is forced to have only line of text, it is forced by the system not to contain new line characters ("\n"). What you can do here is to use UITextViews with disabled scrolling and break any input into lines and fill other UITextViews manually with the result.

Have a look at this answer about faking UITextField with UITextView: https://stackoverflow.com/a/37187098/1689376