• 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: Insert Picture in TextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Insert Picture in TextView


  • Subject: Re: Insert Picture in TextView
  • From: Scott Anguish <email@hidden>
  • Date: Sun, 2 Jun 2002 14:24:59 -0400

On Sunday, June 2, 2002, at 09:12 AM, Albert Atkinson wrote:

Hello!

I have looked all over the cocoa documentation and can not find what I am looking for. I would like to hook up a button so that when the user clicks it then the action will place a picture in a text view called "icon2" (which is in the project).
\


You want to create an NSMutableAttributedString with an attachment for the icon.

You can make a new NSAttributedString with an attachment by calling
+attributedStringWithAttachment: and passing the NSTextAttachment as the
argument.

Then, you can append the NSAttributedString onto the textBox's
textStorage using

[[textBox textStorage] appendAttrbutedString:myStringWithTheAttachment]


- (IBAction)appendAnImage:sender;
{
NSTextAttachment *theAttachment;
NSFileWrapper *theWrapper = [[[NSFileWrapper alloc]
initWithPath:[[NSBundle mainBundle] pathForResource:@"image"
ofType:@"tiff"]] autorelease];
theAttachment = [[[NSTextAttachment alloc]
initWithFileWrapper:theWrapper] autorelease];
[[theTextView textStorage]
appendAttributedString:[NSAttributedString
attributedStringWithAttachment:theAttachment]];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Insert Picture in TextView (From: Albert Atkinson <email@hidden>)

  • Prev by Date: RE: Document-specific data with RTFs
  • Next by Date: DeveloperTools and simple question
  • Previous by thread: Re: Insert Picture in TextView
  • Next by thread: How to put an icon in the menu bar?
  • Index(es):
    • Date
    • Thread