Reputation: 190
I am trying to achieve something like this for iOS in Objective C.
The fill in the blanks(UITextField
) should be inline, and should be able to have its own inputType.
Also, each View is a type of cell.contentView
of a UITableViewCell
.
My current approach is to find the length of string and also calculate the wrapping content length to the next line. Calculate the x
's and y
's for UITextField
and add another UILabel
after the UTextField
Is there any other approach other than this?
Upvotes: 3
Views: 821
Reputation: 4047
I think your solution of separating the UILabels and calculating their required positions is a good one for versions lower than iOS9, but if you can count on iOS, UIStackView can dramatically simplify the process for you. You can read more about the process in this tutorial: UIStackView Tutorial
Good luck!
Upvotes: 0
Reputation: 1622
As EmilioPelaez says, this is not exactly an answer to your question, but a suggestion:
You can use a collection view with an horizontal flow for each "sequence" (i.e. UILabel-UItextfield-etc...)
That collection view has 2 kind of cell:
Coupled with:
My current approach is to find the length of string and also calculate the wrapping content length to the next line.
You may be able to easily adjust the width of the different cells, hide a uitextfield (if needed) and display a more dynamic "sequence" (if needed)
Upvotes: 3
Reputation: 19884
This is not exactly an answer to your question, instead it's a suggestion for a different interaction.
I think that instead of using inline textFields, you could use a UILabel with an attributed string, and in where the textFields would be, you add a different character with a different color that you can tap (For example, this character ✚).
When tapped, you can show an overlay with a text input, and once that input is completed, you update the label with the text (still tappable, and with a different color).
I think this answer might also be relevant: Detecting taps on attributed text in a UITextView in iOS
Upvotes: 1