Reputation: 131
I am facing a problem placing a large text into multiple UITextView/UILabel. Example: Please see the attached picture ,it explains my problem. assume three boxes are UITextViews or UILabels. Text will get from server as a complete one NSString, Now challenge is to place the text in the boxes (UITextView/UILabel).
could anyone please help me in solving this problem.
Upvotes: 0
Views: 630
Reputation: 1089
A UIWebView
might be more suitable for the task of laying out a page. You could then use html with CSS floats to achieve the effect you're looking for.
If you do not want to use UIWebView
, I suggest looking at Core Text for layout.
Upvotes: 2
Reputation: 4932
If you have bounding box for those elements, than you can easily implement this logic by iterating usage of method - (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode
and removing by one word from string till returned size will fit into bounding box for corresponding section, than truncate text to place where you stop removing words and complete with other sections.
Upvotes: 1