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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:07:04+00:00 2026-05-22T15:07:04+00:00

how to find what text is visible in a scrollable, non-ediable UITextView? for example

  • 0

how to find what text is visible in a scrollable, non-ediable UITextView?

for example i may need to show next paragraph, then i want to find the current visible text range and use it to calculate the appropriate range and use scrollRangeToVisible: to scroll the text view

  • 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-22T15:07:05+00:00Added an answer on May 22, 2026 at 3:07 pm

    The way i would do it is to compute all the sizes of each paragraph. With sizeWithFont:constrainedToSize:lineBreakMode:

    you will then be able to work out which paragraph is visible, from the [textView contentOffset].

    to scroll, dont use scrollRangeToVisible, just use setContentOffset: The CGPoint y parameter for this should either be the sum of all the height sizes to the next paragraph, or just add the textView.frame.size.height, if that is closer than the beginning of the next paragraph.

    This make sense?

    in answer to comment requst code bellow (untested):

      CGFloat paragraphOffset[MAX_PARAGRAPHS];
    
        CGSize constraint = CGSizeMake(widthOfTextView, 999999 /*arbitrarily large number*/);
        NSInteger paragraphNo = 0;
        CGFloat offset = 0;
    
        for (NSString* paragraph in paragraphs) {
            paragraphOffset[paragraphNo++] = offset;
            CGSize paragraphSize = [paragraph sizeWithFont:textView.font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
            offset += paragraphSize.height;
        }   
    
        // find visible paragraph
        NSInteger visibleParagraph = 0;
        while (paragraphOffset[visibleParagraph++] < textView.contentOffset.y);
    
    
        // scroll to paragraph 6
        [textView setContentOffset:CGPointMake(0, paragraphOffset[6]) animated:YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to find any text in a file that matches a regexp of
I need to find the text 'ifeq ($(Param1)' using grep. I try to assign
Firefox has this nice find-a-text-on-the-page dialog, which is non-modal and shows up at the
What should be the RegEx if I want to find the text between the
Basically, I want to use BeautifulSoup to grab strictly the visible text on a
I need to find the width of the text that is drawn on the
How to find the text field data has \n in mysql? for ex :
Am trying to find some text only if it contains english letters and numbers
browsing some html code I find a text input coded as: <input type=text name=Email<%=orderRow.ID
what is a regex to find any text that has 'abc' but does not

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.