I am creating a natural language form and whenever a user enters an input that is quite large, I want the whole line to move to the next line (just like a UITextView ). Right now, I get this result: 
This indicates two obvious problems: for one: the element that presses UITextField should go to the next line, and secondly, when canceling back, the element that was "pushed" is not "thrown" into place. In addition, UITextField should go to the next line when exiting view.bounds . Is it arbitrary to use a UITextField or a UITextView to use. It should be applicable to the situation in Figure 2.
This is a more graphical approach to what I'm trying to achieve: 
How can i solve this? And is this the right approach?
Update
Robert's answer is very good, along with some errors that he still has, there is also the problem that he is not flexible. I started refactoring the code and tried to subclass UITextField and UITextView , following Robert's approach.
When subclassing the code, there should be some delegation using UITextField to UITextView . Secondly, each part of the sentence should be divided whenever there is a UITextField between them, but I feel that it can be hardcoded in VC as well. Constraints also need to be converted to code.
Whenever I have a solution to any of these problems, I update the question and hope you get a flexible solution :)
source share