Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9012001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:53:16+00:00 2026-06-16T02:53:16+00:00

I have a UITextView where content is aligned by NSTextAlignmentJustified. In the cellForRowAtIndexPath: add

  • 0

I have a UITextView where content is aligned by NSTextAlignmentJustified. In the cellForRowAtIndexPath: add this text view to cell content view and change frame according it’s content by

UITextView *commentsTextView = (UITextView *)[self getCommentField:comment];
[cell.contentView addSubview:commentsTextView];
CGRect tempFrame = commentsTextView.frame;
tempFrame.size.height = commentsTextView.contentSize.height;
commentsTextView.frame = tempFrame;

So far, so good. Now, how to detect contentSize of that view for heightForRowAtIndexPath:?
I tried

NSString *comment = [[self.allComments objectAtIndex:indexPath.row] objectForKey:@"commentText"];
CGSize constraintSize = CGSizeMake(315.0f, MAXFLOAT);
CGSize size = [comment sizeWithFont:[UIFont systemFontOfSize:14.0]
                  constrainedToSize:constraintSize
                      lineBreakMode:NSTextAlignmentJustified];

Also I tried lineBreakMode:NSLineBreakByWordWrapping and so. But cell height is always smaller when text is long, because there seems to be no way how to coumpute size of justified text (because of the white spaces in the middle of text). Font is same.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:53:18+00:00Added an answer on June 16, 2026 at 2:53 am

    OK, i got it. UITextView has 8 pixels insect from each side, co my CGSizeMake(315.0f, MAXFLOAT); have to be CGSizeMake(299.0f, MAXFLOAT);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITextView that has a lot of content. I have a button
I have a UITextView that works well, till it's content is larger than it's
I have HTML Content which was being displayed in a UITextView . The next
I have UITextView subviews inside a UITableViewCell . When user taps on the cell
In a UITextView have a text which is for readonly and dont want any
I have a UITextView which I am using to display text. Along the side
I have an UITextView which is for instance 380 characters in length: NSLog(@aTextView.text lenght
I have one UITextView which is on the bottom of view. When user tap
I have a UITextView , which sets its text dynamically from an RSS feed.
I have a UITextView, which sets its text dynamically from an RSS feed. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.