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
3
votes
1 answer

Computing text size with NSLayoutManager

I'm working on a view which uses TextKit framework to typeset text in columns like this: I use my UIView's bounds with edge insets (black rectangle) to compute 10 CGRects which I then transform into NSTextContainers (red rectangles). In drawRect: I…
Petr Mánek
  • 1,046
  • 1
  • 9
  • 24
3
votes
1 answer

'-[UITextView autocapitalizationType]: unrecognized selector sent to instance?

I would like to create custom subclasses(SubCustomView) of uiview when click on button and added uitextview class on SubCustomView as subview. when i initiate uitextview i use initWithFrame:textContainer: method. when i used this method, the project…
Prasad G
  • 6,702
  • 7
  • 42
  • 65
2
votes
0 answers

How to get height of string with maximum lines using NSTextStorage?

I am trying to get the height of an attributed string (for any font, any language, any strange utf8 characters, etc). I found this interesting topic at Badoo Chatto about different solutions: https://github.com/badoo/Chatto/issues/129 And the…
Kalzem
  • 7,320
  • 6
  • 54
  • 79
2
votes
1 answer

How can i remove vertical line from UITextView and typed text from left side in DALinedTextView?

I'm using DALinedTextView for lined UITextView. I want to remove red vertical line and type text from left side. How can i do this. Thanks in advance.
user5955394
2
votes
1 answer

TextContainer isn't resizing while changing bounds of UITextView

After resizing textView, I want textContainer to be the same size (I want text to be the same width as resized textView) as textView. So what I am doing right now is I create a UITextView programatically, then (with or without text inside textView)…
K.K
  • 101
  • 3
  • 9
2
votes
0 answers

Exact height of NSTextContainer

I have a method used to calculate the exact height size for a text container. The method returns not correct values when trying to measure the height of an attributed string filled with arabic html content. This is the code used : -…
2
votes
2 answers

Adding Multiple NSTextContainers to an NSLayoutManager

I notice that you can add multiple text containers to a layout manager in Objective-C using the addTextContainer:(NSTextContainer *)textContainer selector. Using TextKit, I've only ever had to add one text container, and when messing around with…
2
votes
0 answers

How does one manually tell NSTextContainer to recalculate the lineFragmentRects?

In my application, I have been adding support for NSTextView allowing subviews to work naturally with the text editor. (For example, pressing "enter" drops every subview lower than the insertion point, and text wraps around subviews.) I have…
ra1nmaster
  • 662
  • 1
  • 8
  • 21
2
votes
1 answer

Laying out text in NSTextView around a subview

What I’m trying to do is have an NSTextView and add custom NSView subviews to it, but have it so the text can layout around the subviews. Right now, I can easily add a subview to the textview but of course, that goes into the textview and the text…
jbrennan
  • 11,943
  • 14
  • 73
  • 115
1
vote
0 answers

How to replace specific text by some visually specific entity in UITextView (like Xcode placeholders)

I know the title can be unclear, it's just because I don't know how to explain it better... So here's what I try to achieve: I would like my user to type into a UITextView and, like in Xcode, if some pattern is detected, for instance <#TAG#>,…
Zaphod
  • 6,758
  • 3
  • 40
  • 60
1
vote
1 answer

UITextView removing interim blank lines on resize

I have a UITextView that can potentially change size. Scrolling is disabled. Here what's happening: Is there any way to prevent this strange behaviour but also keep the lineBreakMode to .byTruncatingTail? (removing this option produces the expected…
Astri
  • 575
  • 4
  • 10
1
vote
1 answer

UITextView does not fit NSTextContainer exactly

I just created a custom method using a TextKit stack but am confused by what appears to be a difference between the size of NSTextContainer and the NSTextView frame size. The text has a white border and I’d like to know how to get rid of it (see…
1
vote
1 answer

NSLayoutManager/NSTextContainer Ignores Scale Factor

I am attempting to measure an NSAttributedString's height given a constant width using the following method: -(CGFloat)calculateHeightForAttributedString:(NSAttributedString*)attributedNotes { CGFloat scrollerWidth = [NSScroller…
Deadpikle
  • 356
  • 6
  • 22
1
vote
0 answers

Multiple NSTextContainers do not work properly with UIPageViewController

I have a long text (multiple screen pages) stored in an NSTextStorage. I instantiate an NSLayoutManager() and add the textStorage to it. Then I keep adding NSTextContainers of specific size until I use up the whole text. The containers are also…
Jacklin Heirdom
  • 131
  • 1
  • 1
  • 11
1
vote
1 answer

Get right point of glyph in NSLayoutManager with linebreak-mode enabled

I'm trying to get an actual point of selected character in NSTextContainer: func handleTouch(gestureRecognizer: UIGestureRecognizer) { var location = gestureRecognizer.locationInView(self) let startPoint =…
Jauzee
  • 120
  • 2
  • 18