nslayoutmanager

Fitting NSlayoutManager into UIView

怎甘沉沦 提交于 2019-12-12 06:37:11
问题 I have set up a UIView with NSLayoutManager (TextKit) and the UIView is placed in a UIScrollView. Im having trouble resizing the UIView to the size of the text so that It can be scrolled. Currently the text fills the screen but the scrollView doesn't really scroll to the rest of it. UIView Code: - (void)drawRect:(CGRect)rect { [super drawRect:rect]; NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; long value = [prefs integerForKey:@"Daven"]; if((int)value == 0){ string =

How to get the range of characters that are visible from within -textStorageDidProcessEditing:?

孤街醉人 提交于 2019-12-11 01:58:42
问题 For my syntax highlighting implementation, I observe changes to an NSTextView using -[<NSTextStorageDelegate> textStorageDidProcessEditing:] . - (void)textStorageDidProcessEditing:(NSNotification *)notification { if (!self.languageGrammar) return; NSTextStorage *textStorage = self.textView.textStorage; NSRange glyphRange = [self.textView.layoutManager glyphRangeForBoundingRect:self.scrollView.documentVisibleRect inTextContainer:self.textView.textContainer]; NSRange editedRange = [self

NSLayoutManager hides new line characters no matter what I do

大城市里の小女人 提交于 2019-12-11 00:52:42
问题 I'm trying to show invisible characters like the new line character in my NSTextView subclass. The usual approach like overriding drawGlyph method of NSLayoutManager is a bad idea because it's too slow and not work properly with multi-paged layout. What I'm trying to do is to override the setGlyph method of the NSLayoutManager so it would replace invisible "\n" glyph with "¶" glyph and " " with "∙". And it works on the " " space glyphs but has no effect on the new line characters. public

Why do I fail to get textContainer's rect by using “usedRectForTextContainer”

血红的双手。 提交于 2019-12-11 00:41:31
问题 I learned the answer by NAlexN in this Question (Create tap-able "links" in the NSAttributedString of a UILabel?), and write a demo by myself. However, it is unluck for me to work the demo out. Here is my code: (everyone can copy following code to a new project directly to make a test) #import "ViewController.h" @interface ViewController () { UILabel* label; NSTextContainer *textContainer; NSLayoutManager *layoutManager; } @end @implementation ViewController - (void)viewDidLoad { [super

iOS 7 UITextView: Size of nstextattachment getting 2x after reopening the application

北慕城南 提交于 2019-12-10 04:22:30
问题 I am building a note editor using the Text Kit in ios7. Earlier I had trouble in rendering of custom size NSTextAttachment's as it was slowing down the rendering to a great extent.I solved the issue by scaling the images and then adding them to textview.You can find my answer in iOS 7.0 UITextView gettings terribly slow after adding images to it After scaling the images the textview rendering runs fine without any lag.The attributed text of textview is stored in core data.During a running

iOS 7 UITextView: Size of nstextattachment getting 2x after reopening the application

白昼怎懂夜的黑 提交于 2019-12-05 05:15:43
I am building a note editor using the Text Kit in ios7. Earlier I had trouble in rendering of custom size NSTextAttachment's as it was slowing down the rendering to a great extent.I solved the issue by scaling the images and then adding them to textview.You can find my answer in iOS 7.0 UITextView gettings terribly slow after adding images to it After scaling the images the textview rendering runs fine without any lag.The attributed text of textview is stored in core data.During a running session of application the textview displays the images correctly.Even after saving the attributed text in

UITableView in iOS 7 not scrolling to correct location when editing UITextView in cell

空扰寡人 提交于 2019-12-04 19:51:25
问题 I have a table view with static cells. One cell contains a UITextView and the heightForRowAtIndexPath: is calculated dynamically so that the cell is always tall enough to accomodate the text (that part took some work under iOS 7, actually, as it's no longer possible to simply ask the textView for its contentSize ). When I tap within the text view to start editing, the keyboard animates into place, the contentInsets on the tableView are automatically adjusted to account for this (ie, bottom

UITextView contentSize changes and NSLayoutManager in iOS7

点点圈 提交于 2019-12-03 12:36:57
问题 The problem: UITextView silently changes it's contentSize in some situations. The simplest case textView with large text and keyboard. Just add UITextView outlet and set - viewDidLoad as: - (void)viewDidLoad { [super viewDidLoad]; // expand default "Lorem..." _textView.text = [NSString stringWithFormat:@"1%@\n\n2%@\n\n3%@\n\n4%@\n\n5", _textView.text, _textView.text, _textView.text, _textView.text]; _textView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive; _textView

UITableView in iOS 7 not scrolling to correct location when editing UITextView in cell

眉间皱痕 提交于 2019-12-03 12:02:49
I have a table view with static cells. One cell contains a UITextView and the heightForRowAtIndexPath: is calculated dynamically so that the cell is always tall enough to accomodate the text (that part took some work under iOS 7, actually, as it's no longer possible to simply ask the textView for its contentSize ). When I tap within the text view to start editing, the keyboard animates into place, the contentInsets on the tableView are automatically adjusted to account for this (ie, bottom inset of 216px for iPhone portrait orientation), the cursor / caret becomes visible, and then the table

Using NSLayoutManager to calculate frames for each glyph

吃可爱长大的小学妹 提交于 2019-12-03 10:39:27
On this thread, Core Text calculate letter frame in iOS , they were able to calculate the frame of each glyph very precisely using Core Text. The final rects hug the actual drawn glyphs perfectly. Using NSLayoutManager's boundingRectForGlyphRange:inTextContainer: doesn't seem to return the glyph bounding boxes that precisely: And the returned rects don't fully enclose more complex fonts (Zapfino example): Does anyone know how to replicate the results from the above mentioned discussion without going into Core Text under iOS 7 only apps? Thanks. ugiflezet I've found a solution for this issue or