• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iPhone app with searchable text that highlights
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iPhone app with searchable text that highlights


  • Subject: Re: iPhone app with searchable text that highlights
  • From: Conrad Shultz <email@hidden>
  • Date: Mon, 16 Aug 2010 14:16:54 -0700

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 8/16/10 9:58 AM, Jonathan Schmidt wrote:
> I would like to display this in a ScrollView.  From what I have read
> so far, it seems that the following may be the best way:
>
> 1. Copy the String into an NSMutableAttributedString. 2. Add the
> attributes to the string. 3. Push a new view onto the stack with a
> ScrollView. 4. Use CoreText to draw the NSMutableAttributedString
> inside the ScrollView.
>
> I think I can manage 1-3.  How do I accomplish #4 when I don't know
> the Y value for the CGRect?  Anyone have any sample code to use Core
> Text to draw an NSMutableAttributedString into a ScrollView?

I honestly have not yet studied implementation of Core Text so I can't
answer that with any specificity.  It's on my to-do list, but I'm not
there yet.

- From my admittedly hasty scan of the Core Text Programming Guide, it
certainly does seem as if this might be overkill for your needs,
somewhat reminiscent of drawing everything with Core Graphics if all you
really need is an image with a border and text label.

If you can just convert your NSAttributedString into an NSString
containing simple HTML (or HTML w/ CSS), a UIWebView would give you just
what you want, scrolling included for free.

That said, the CT Programming Guide is at:
http://developer.apple.com/iphone/library/documentation/StringsTextFonts/Conceptual/CoreText_Programming/Introduction/Introduction.html

My _completely_ uninformed suggestion (others on the list who know
something about Core Text: please chime in!) would be that you probably
can use CTFramesetterSuggestFrameSizeWithConstraints() to get the frame
size (i.e. the Y value you are concerned about) by constraining the
width to your UIScrollView width and height to CGFLOAT_MAX.

I'm gleaning this naive idea from the pertinent CTFramesetter docs -
http://developer.apple.com/iphone/library/documentation/Carbon/Reference/CTFramesetterRef/Reference/reference.html

Good luck - I'd love to hear what you end up with if you go the CT
route, since I will eventually rewrite our code to use Core Text.

- --
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFMaarGaOlrz5+0JdURAgx/AJ4i74CtG1nsOmludCa/2c/hkccS5gCfSN2N
OvMbmTEBetNMo9XcgsJwYV0=
=Ibe4
-----END PGP SIGNATURE-----
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >iPhone app with searchable text that highlights (From: Jonathan Schmidt <email@hidden>)
 >Re: iPhone app with searchable text that highlights (From: Conrad Shultz <email@hidden>)
 >RE: iPhone app with searchable text that highlights (From: Jonathan Schmidt <email@hidden>)

  • Prev by Date: Re: Erratic Cocoa Behavior
  • Next by Date: Re: Using Apple icons
  • Previous by thread: RE: iPhone app with searchable text that highlights
  • Next by thread: controlling keyboard cursor on NSTextFieldCell
  • Index(es):
    • Date
    • Thread