Questions tagged [nstextcontainer]

NSTextContainer is an iOS class that defines a region in which text stored in an NSTextStorage object is displayed using an NSLayoutManager object.

47 questions
14
votes
5 answers

UITextView textContainer exclusion path fails if full width and positioned at top of textContainer

In iOS 8, I'm trying to add a UIImageView as a subview of a UITextView, similar to what's shown here - but with the text below the image. I want to do it using an exclusion path because on other devices, I might position the image differently…
Jim Rhoades
  • 3,310
  • 3
  • 34
  • 50
10
votes
2 answers

NSTextContainer exclusionPaths freezes app and uses 99% CPU on iOS 7.1 - workaround?

I'm trying to exclude a square in a UITextView using NSTextContainer's excludePaths, like so: NSTextStorage* textStorage = [[NSTextStorage alloc] initWithAttributedString:attributedString]; NSLayoutManager *layoutManager = [NSLayoutManager…
René
  • 513
  • 3
  • 16
9
votes
1 answer

Using a CALayer to highlight text in a UITextView which spans multiple lines

This is a continuation of Getting CGRect for text in a UITextView for the purpose of highlighting with a CALayer. I'm having trouble with getting the correct rectangle for the ranges in each line fragment. NSString* searchString = @"Returns the…
Myron Slaw
  • 886
  • 9
  • 21
7
votes
2 answers

Sequential selection among multiple NSTextViews

I have a bunch of NSTextViews that I would like to share a single selection. I basically want this to behave like selecting text on a web page, where there are multiple text views but you can drag to sequentially select text among them. I found this…
indragie
  • 18,002
  • 16
  • 95
  • 164
5
votes
2 answers

NSLayoutManager with multiple NSTextContainers causes UITextViews to not be selectable/editable

I am trying to achieve a multi page text editing layout, as in Pages, MS Word, ... . On OS X I can achieve this by creating one NSLayoutManager with one NSTextStorage for multiple NSTextViews. Each NSTextView has its own NSTextContainer. See below…
5
votes
3 answers

Get index of character in UILabel from tap

I'd like to get the index for the tapped character on a UILabel. I've subclassed a UILabel. In my awakeFromNib() I have this: layoutManager = NSLayoutManager() textStorage = NSTextStorage(attributedString: self.attributedText) …
SirRupertIII
  • 12,324
  • 20
  • 72
  • 121
5
votes
2 answers

What is Causing this Unwanted Content Inset with UITextView in iOS 8 (not there in iOS 7)?

I've been creating UITextViews programatically, using auto layout, in iOS 7. Something like this: _textView = [UITextView new]; _textView.translatesAutoresizingMaskIntoConstraints = NO; _textView.font = [UIFont…
Gavin Hope
  • 2,173
  • 24
  • 38
5
votes
2 answers

Getting CGRect for text in a UITextView for the purpose of highlighting with a CALayer

I am trying to draw a transparent CALayer in a UITextView in order to highlight matched text in a search. I've figured out the correct way to do this, but still haven't found the correct coordinates. I need to find the origin of the text container.…
Myron Slaw
  • 886
  • 9
  • 21
4
votes
0 answers

Update attributedText on a dequeued cell UITextView make the app freeze

I'm currently stuck down a big wall... I'm using custom UITableViewCell containing UITextView containing custom NSTextAttachment images. Each NSTextAttachment overrides the - (CGRect)attachmentBoundsForTextContainer:(NSTextContainer *)textContainer…
4
votes
2 answers

NSLineBreakByTruncatingTail on UITextView removing new line breaks

I have a UITextView with attributedText that has multiple new line breaks included in its attributed string. NSMutableAttributedString *info = [[NSMutableAttributedString alloc] initWithString:@""]; NSAttributedString *title = [[NSAttributedString…
vpetro
  • 83
  • 6
4
votes
3 answers

In my programmatically instantiated UITextView (initialized with NSTextContainer) the .text property is always nil

[UPDATED w/ SOLUTION and WORKING CODE in bottom section] In -viewDidLoad I alloc, initWithFrame: Add myTextView to subView Set some basic properties (alignment, background color, text color, etc) Set default text The .text does not appear.…
3
votes
0 answers

iOS UITextView's textContainer Text Cut Off When Resizing

I have a UITextView that I am resizing using a UIPinchGestureRecognizer: @IBAction func handlePinch(recognizer : UIPinchGestureRecognizer) { if let view = recognizer.view { view.transform = CGAffineTransformScale(view.transform, …
B. Wolf
  • 81
  • 1
  • 5
3
votes
1 answer

Setting a UITextView exclusion path dynamically while scrolling up causes an infinite loop

I have a UITextView in a UIViewController. In front of that UITextView is another UIViewController containing two buttons. The two buttons are static and they obscure the text in the text view. What I am trying to achieve is an exclusion path on…
3
votes
0 answers

UITextView's NSTextContainer wrong position on text view height NSLayoutConstraint change

I have subclassed UITextView to make it return an intrinsic content size like this: - (void) layoutSubviews { [super layoutSubviews]; if (!CGSizeEqualToSize(self.bounds.size, [self intrinsicContentSize])) { [self…
gsempe
  • 5,371
  • 2
  • 25
  • 29
3
votes
1 answer

get text in NSTextContainer

I have a NSOrderedSet of paragraphs with NSString content. Looping through all, a large string is created and given NSTextStorage. But with that all the paragraphs are lost. The code below allows me to count the pages and present the content in…
Giwan
  • 1,564
  • 14
  • 17
1
2 3 4