Skip navigation
This discussion is archived

UIScrollView

1225 Views 2 Replies Latest reply: Oct 28, 2009 5:13 AM by MiniRobinho RSS
MiniRobinho Calculating status...
Currently Being Moderated
Oct 27, 2009 2:32 PM
Two questions about using a UIScrollView - you can't search text in it, and jump to the next use of the word and/or highlight it? And there's no other way to display scrollable text that can jump to a specific word when searched?

Secondly can you set the UIScrollView to scroll to a particular line or maybe a designated content rectangle (i.e. state the content area frame)?

Thanks
Macbook, Mac OS X (10.5.8)
  • RayNewbie Level 5 Level 5 (6,810 points)
    Currently Being Moderated
    Oct 27, 2009 8:58 PM (in response to MiniRobinho)
    UIScrollView doesn't do any of the things you asked about, but UITextView does.
    MiniRobinho wrote:
    search text in it, and jump to the next use of the word and/or highlight it?

    You can obtain the text at any time from the NSString* text property. So you can search for any substring and obtain its index range with NSString methods, then highlight that range and scroll it to visibility with UITextView methods. UISearchBar would normally be used to obtain the search key.
    scroll to a particular line or maybe a designated content rectangle (i.e. state the content area frame)?

    You could use scrollRangeToVisible: after finding the index of the target substring in the text. Apropos our recent discussion on pagination, there's no easy way to find the bounding rectangle of a substring (nor anyway to determine the substring inside a given rectangle) unless we have wrapped the text ourselves.

    Hope that's what you were looking for!
    \- Ray
    MacBook, Mac OS X (10.5.5)

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.