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

  • SEARCH
  • Home
  • 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 4560334
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:54:58+00:00 2026-05-21T17:54:58+00:00

On what factors does the wrapping of the text inside a textview depends. Width

  • 0

On what factors does the wrapping of the text inside a textview depends. Width of my textview is 160 px and I calculated the width of the incoming text using below mentioned code and it comes out to be 157 px but this text is wrapped in 3 lines… Why so?

CGSize size = [myText sizeWithFont:textViewFont 
            constrainedToSize:textView.frame.size 
            lineBreakMode:UILineBreakModeWordWrap];

CGFloat textWidth = size.width;

I thought of dividing width of text with width of the textview to get the number of lines. But calculation returns me 1 whereas I can see 3 lines coming in textview on simulator.

  • 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-05-21T17:54:58+00:00Added an answer on May 21, 2026 at 5:54 pm
    - (CGSize)sizeWithFont:(UIFont *)font
         constrainedToSize:(CGSize)size
             lineBreakMode:(UILineBreakMode)lineBreakMode
    

    Calculates the size for a string if it would be drawn constrained by the size given as an argument, if the string is too long for the given size constraint it will get truncated to fit.

    To get the width of the string if it’s drawn on a single line with no constraints use:

    - (CGSize)sizeWithFont:(UIFont *)font
    

    see: http://developer.apple.com/library/ios/#documentation/uikit/reference/NSString_UIKit_Additions/Reference/Reference.html

    NOTE: As of iOS7

    - (CGSize)sizeWithFont:(UIFont *)font
    

    is deprecated, instead use:

    - (CGSize)sizeWithAttributes:(NSDictionary *)attrs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What are the key factors on using different calling conventions? When does someone know
Why does this code return the sum of factors of a number? In several
What factors determine which approach is more appropriate?
What factors indicate that a project's solution should not be coded in a dynamic
I need to find out the prime factors of over 300 billion. I have
I will be teaching a class sson, and I need to explain what factors
When I am creating a new database table, what factors should I take into
Does anybody know the mathematics behind an attack on DSA where modulus p has
Does it actually matter which CDN you use to link to your jquery file
Does anyone happen to know what the maximum length of a method name is

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.