(please forgive my english)
I’m new at IOS developing but I’ve a good skill on other programming languages (mainly c#).
I’m trying to develop a test app with a main window.
Inside that window there is a scrollview with fixed size. inside that scrollviewer there is a view containing some stacked couples of one TextField and one Label: I can’t know – ad design time – how many “rows” of them I have to put into.
My problems is:
I can put on the view the first couple (a textfield and, next, a label). Label size can be one or several rows high ,so I’ve to set multiline and sizeToFit
How can I put the second couple (and so on) without overlap the existing labels..? I can’t use a table because between rows there are other labels (title of section).
Do I have to calculate the height of each label and programmatically calculate where to draw the next? Is there a more efficient way?
I don’t need code, please just some hints or some keyword to googling on.
Many thanks.
(please forgive my english) I’m new at IOS developing but I’ve a good skill
Share
I don’t see why you can’t use a
UITableView, you can set up cells with all the controls you need in it. Either way, using aUITableviewwon’t make the job any easier (just more memory efficient if you have many rows).The only way that I see is, as you said, to calculate where the next ‘row’ should be placed (depending on the height of your previous rows). You’ll also need to calculate the entire height, in order to set it to the
contentSizeof theUIScrollView.Instead of
UILabelyou can also use a noneditableUITextView, since it’ll be easier to get its size (after you set the text, you can set the size of aUITextViewto be equal to itscontentSize)