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

141 questions
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
  • 561
  • 6
  • 26
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..." which 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
  • 3,058
  • 4
  • 34
  • 73
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
  • 121,420
  • 116
  • 450
  • 651
0
votes
1 answer

How to insert NSTextAttachment into NSAttributedString?

How do I insert an NSTextAttachment at a specific location in an NSAttributedString?
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
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
  • 765
  • 6
  • 18
0
votes
1 answer

Search word in attributedString from backword and get range Objective-C

How do I search the space "" (space) in an attributedString from the end of the string backwards and then get the range of that space? problem : As you can see jumps is in two line which is not correct. The logic i want to implement is like that,…
sanjeet
  • 1,539
  • 15
  • 37
0
votes
0 answers

ReplaceCharactersInRange of NSAttributedString

I want to replace a substring (e.g. @"replaceString") of an NSAttributedString (which contains NSTextAttachments in it) with another NSAttributedString. I have tried to work with the mutableString of NSMutableAttributedString, but result is omitting…
0
votes
0 answers

ios UITextView repeat shown NSTextAttachment in markedText with Chinese input. [ios7 5c]

I want to insert a 'text image' into the textView using the NSTextAttachment. It's fine when the text is English, but something wrong when the text is Chinese. the code: - (IBAction)insertAt:(id)sender { UIColor *color = [UIColor redColor]; UIFont…
0924wuyr
  • 13
  • 3
0
votes
1 answer

Text gets reset after inserting an image in an NSAttributedString

I have a UITextView and I am inserting images into using NSTextAttachment. The problem is that when the user moves the cursor after the image and begins to type text, instead of using the font used everywhere else in the UITextView, it resets to a…
Senseful
  • 86,719
  • 67
  • 308
  • 465
0
votes
1 answer

Interactable UITextField above NSTextAttachment

I previously developed a Mac app using NSTextAttachmentCell, and applying a NSTextfield to it, so that a textfield would appear above the inserted image. Note that this NSTextAttachmentCell is inserted into an NSTextView. Now, on iOS, I have tried…
Naoto Ida
  • 1,275
  • 1
  • 14
  • 29
0
votes
3 answers

How can I Add second NSTextAttachement image in uilabel?

I wanted to add image in UILabel along with text. However I used NSTextAttachment to add image at the end of UILabel text. I have subclass it to to fit the size of image to my text. Now I want to add one more image in the beginning of the text, we…
Parth Pandya
  • 1,460
  • 3
  • 18
  • 34
0
votes
2 answers

Change NSTextAttachment image don't work immediately even in main queue

I use NSTextAttachment to Display a placeholder image . when click this image , I want to show another image. I do this in UItextView delegate method : -(BOOL)textView:(UITextView *)textView shouldInteractWithTextAttachment:(NSTextAttachment…
james
  • 643
  • 4
  • 24
0
votes
1 answer

NSTextAttachment cover the text when use textkit

I want to insert image in UITextView, so I use textkit and NSTextAttachment. But when I insert image, the image display above the content in UITextView, the effect like below: and the code is like this: // // TextKitView.m // TextKit // // …
lixiaoyu
  • 378
  • 5
  • 18
1 2 3
9
10