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 9175085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:51:26+00:00 2026-06-17T16:51:26+00:00

MonoTouch makes the sizeWithFont methods available through UIView , but it seems to return

  • 0

MonoTouch makes the sizeWithFont methods available through UIView, but it seems to return the font’s LineHeight no matter how long the string I pass to it.

string someString = "test string";
UIFont someFont = UIFont.SystemFontOfSize(13f);
SizeF sizeToDisplay = someUIView.StringSize(someString, someFont, Bounds.Width, UILineBreakMode.WordWrap);
// sizeToDisplay = { Width: 58, Height = 16 }
someString = string.Join(" ", Enumerable.Repeat(someString, 500));
sizeToDisplay = someUIView.StringSize(someString, someFont, Bounds.Width, UILineBreakMode.WordWrap);
// sizeToDisplay = { Width: 304, Height = 16 }

Is there some other method I should be using to find the height needed to display an arbitrary block of text in a UITextView?

  • 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-17T16:51:27+00:00Added an answer on June 17, 2026 at 4:51 pm

    This isn’t specific to MonoTouch, but you’d have to search for the native NSString.sizeWithFont method to find that answer, so this should help other MonoTouch devs in the future.

    For some reason, you will need to hit a different overload for StringSize, one that takes a full SizeF argument instead of a width value. In this case, you just "hack" in a very large height to get the wrapped-text size.

    SizeF sizeToDisplay = someUIView.StringSize(someString, someFont, new SizeF(Bounds.Width, float.MaxValue), UILineBreakMode.WordWrap);
    // For the larger string: sizeToDisplay = { Width: 307, Height = 1600 }
    

    That forWidth overload of StringSize calls over to the native sizeWithFont:forWidth:lineBreakMode: NSString method. For some reason, when you use this overload, it will truncate your string for measurement purposes.

    This method returns the width and height of the string constrained to the specified width. Although it computes where line breaks would occur, this method does not actually wrap the text to additional lines. If the size of the string exceeds the given width, this method truncates the text (for layout purposes only) using the specified line break mode until it does conform to the maximum width; it then returns the size of the resulting truncated string.

    Note about UITextView padding

    As a side note, using a UITextView with the returned StringSize will result in text that requires scrolling to see (UITextView inherits from UIScrollView) because it includes some forced content padding. You will need to also tweak the content offsets to get what you expect.

    someUITextView.ContentInset = new UIEdgeInsets(-8, -8, -8, -8);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a MonoTouch iPhone app, but have come up with a small issue.
I wanted to use monotouch, but unfortunately I don't have $400 to spend. So
MonoTouch preferred, but Obj-C ok too My MainWindow.xib has a NavigationView and a View.
I have a MonoTouch.Dialog DialogViewController which adds a custom UIView to the NavigationItem.Views object.
Several weeks late, but I am finally getting back to updating my MonoTouch iOS
I'm trying to implement zooming functionality using a UIScrollView in MonoTouch but I just
I'm writing an app in monotouch which also makes use of a C++ library,
MonotouchDialog makes it very easy to create UITableView Dialogs, but sometimes questions like that
I have been trying to use protobuf-net with MonoTouch but I have no idea
How do you use ShareKit with MonoTouch? The MonoTouch Bindings project on GitHub seems

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.