Questions tagged [nstextattachment]

NSTextAttachment class is used for embedding images into attributed strings(NSAttributedString). Supported by iOS 7.0+, masOS 10.10+, tvOS 9.0+ and watchOS 2.0+

NSTextAttachmentobjects contain either anNSData object or anFileWrapper object, which in turn holds the contents of the attached file.

Docs: NSTextAttachment reference

135 questions
0
votes
0 answers

iOS - How to get the position of attachment image in UITextView

Does anyone know how get the NSTextAttachment image's position centre in UITextView? I'm working on an app that allow user to input text and image in a UITextView, and when user click on an image, it will show the image viewer for all images. This…
mmk
  • 187
  • 3
  • 7
0
votes
1 answer

How can i show gif in UITextView with NSTextAttachment?

I used SD_WebImage to show My gif, like this: code: UIImage *gifImg = [UIImage sd_animatedGIFWithData:[NSData dataWithContentsOfFile:imagePath]]; NSTextAttachment *atc = [[NSTextAttachment alloc] initWithData:nil ofType:nil]; …
L.wind
  • 37
  • 4
0
votes
0 answers

When I drag an image in NSTextAttachment it is an .rtf

I have an NSTextView that display an image like this. NSTextAttachment *attachment = [[NSTextAttachment alloc] init]; NSImage *attachImage = [NSImage imageNamed:@"Settings"]; attachment.image = attachImage; NSAttributedString *attributedString =…
Curt Rand
  • 953
  • 1
  • 6
  • 24
0
votes
3 answers

the image of NSTextAttachment is flipped

NSTextAttachment *attachment = [[NSTextAttachment alloc] init]; NSImage *image = [NSImage imageNamed:@"emotion"];; attachment.image = image; NSAttributedString *attributedString = [NSAttributedString attributedStringWithAttachment:…
jimwan
  • 969
  • 2
  • 19
  • 37
0
votes
0 answers

Image in NSTextAttachment too big and blurry

I'm trying to place an icon (in form of an image) next to a text in a UILabel. The icons are imported into the assets in al three sizes and are not blurry at all when I simply place them in a normal UIImageView. However, within the NSTextAttachment…
0
votes
1 answer

UIImage from custom UIView in Xib returning empty image with black background

Basically, I'm looking out for a way to attach custom UIView from XIB so that it can be use as link preview in UILabel. I'd choose to convert UIView into UIImage as an image can be use in NSTextAttachment which in turn can use in…
iAkshay
  • 645
  • 7
  • 26
0
votes
2 answers

NSTextAttachment is somehow caching the image. Any ideas about how?

When creating a NSAttributedString from an HTML string which contains an image link (https), somehow the downloaded image is cached. How did I came up with this fact? Install app. Open the app. Image is there. Close the app (terminate). Go for…
0
votes
1 answer

How to convert uitextview content to a image in custom size?

I create a uitextview and I can add text and images to it with NSAttributedString and NSTextAttachment self.tvContent = [[UITextView alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height - 64)]; …
user2688045
0
votes
1 answer

Attributed string image replacing text in UItextview

I got an attributed string with an image in a textview, the attributed image is displaying fine. The issue is whenever I add the image it replaces the text inside the textview. I want to add the attributed image and then place the cursor at the end…
Iam Wayne
  • 451
  • 4
  • 22
0
votes
1 answer

Swift: Replace Strings to NSTextAttachment in UITextView after loading styled RTF

In my iOS/swift project I am loading a RTF document to a UITextView with the code below. The RTF itself contains styled text like "... blah blah [ABC.png] blah blah [DEF.png] blah..." wich is loaded to the UITextView just fine. Now, I want to…
daviid
  • 35
  • 5
0
votes
1 answer

iOS - image attachment for the text view changes attributes

I've a UITextView described as follows with the given attributes: lazy var inputTextView: UITextView = { let tv = UITextView() tv.backgroundColor = .white tv.textContainerInset = UIEdgeInsetsMake(12, 12, 12, 12) // Posicionamento do…
Ivan Cantarino
  • 2,628
  • 4
  • 29
  • 62
0
votes
0 answers

Resize NSTextAttachment to fit UITextView width

How do I get all NSTextAttachment's (and ultimately their images) to automatically resize to fit within their UITextView's width?
ma11hew28
  • 106,283
  • 107
  • 420
  • 616
0
votes
1 answer

How to insert NSTextAttachment into NSAttributedString?

How do I insert an NSTextAttachment at a specific location in an NSAttributedString?
ma11hew28
  • 106,283
  • 107
  • 420
  • 616
0
votes
0 answers

How to get value stored in type property of NSTextAttachment?

class AKAttachement: NSTextAttachment{ var tag:Int! var frame: CGRect! var type: String! var url: URL? var completionHandler:((CGRect)->Void)? func configure(type:String, tag:Int,frame:CGRect,_url:URL?) { self.tag…
0
votes
1 answer

How to pull NSImage from NSTextAttachment in NSTextView?

Goal is to allow user to add NSImage(s) to an NSAttributedString in an NSTextView, and then reverse the process and extract the image(s). With code from here, can add image(s) and have them displayed inline. let attributedText =…
JKaz
  • 705
  • 6
  • 15
1 2 3
8
9