iOS Guides | Samples

MonoTouch.UIKit.NSTextStorage Class

A subclass of NSMutableAttributedString that supports Core Text layout management.

See Also: NSTextStorage

Syntax

[MonoTouch.Foundation.Register("NSTextStorage", true)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 7, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
public class NSTextStorage : NSMutableAttributedString

Remarks

iOS 7 introduced "Text Kit," a broad set of APIs and modifications of existing classes, built on MonoTouch.CoreText, that greatly expands the typographical flexibility of iOS.

An NSTextStorage object holds the text that is to be displayed. As with NSMutableAttributedString, application developers can manipulate text styles using NSMutableAttributedString.AddAttribute or NSMutableAttributedString.AddAttributes. The key addition to NSTextStorage is that it maintains references to one or more NSLayoutManagers (NSTextStorage.LayoutManagers) , which are responsible for converting text characters into glyphs and laying them out in accordance with the NSLayoutManagers' associated UITextView and NSTextContainer objects.

If you subclass NSTextStorage, you must override four methods. Two from NSAttributedString (NSAttributedString.LowLevelValue and NSAttributedString.LowLevelGetAttributes) and two from NSMutableAttributedString (AttributedString.LowLevelSetAttributes and NSMutableAttributedString.Replace(NSRange,String)).

The reason why you must override the low-level methods is because NSTextStorage is a very chatty interface that likes to call those methods up to thousands of times for each character that the user enters. So it important to use the low-level interface. You can review some of Xamarin's samples to see how to implement those if you have questions on how to do this.

Since NSTextStorage is a very chatty API,

Related content

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.NSTextStorage are listed below.

See Also: NSMutableAttributedString

Public Constructors

Default constructor, initializes a new instance of this class.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

ChangeInLengthInt32. The change in length for the pending changes.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
DelegateNSTextStorageDelegate. An instance of the MonoTouch.UIKit.NSTextStorageDelegate model class which acts as the class delegate.
EditedMaskNSTextStorageEditActions. The kinds of edits pending for this NSTextStorage.
EditedRangeNSRange. The range in this NSTextStorage in which pending changes have been made.
[read-only]
FixesAttributesLazilyBoolean. Whether this NSTextStorage fixes attributes lazily. Read-only.
[read-only]
LayoutManagersNSObject[]. The NSLayoutManagers associated with this NSTextStorage. Read-only.
WeakDelegateNSObject. An object that can respond to the delegate protocol for this type

Public Methods

AddLayoutManager(NSLayoutManager)
Adds an NSLayoutManager to this NSTextStorage.
Edited(NSTextStorageEditActions, NSRange, Int32)
Indicates a change.
EnsureAttributesAreFixed(NSRange)
Ensures that attributes have been fixed in the given range.
InvalidateAttributes(NSRange)
Invalidates attributes in the specified range.
ProcessEditing()
Activates post-editing operations.
RemoveLayoutManager(NSLayoutManager)
Removes an NSLayoutManager from this NSTextStorage's LayoutManagers collection.

Protected Methods

override
Dispose(Boolean)
Releases the resources used by the NSTextStorage object.

Public Events

DidProcessEditingEvent raised by the object.
WillProcessEditingEvent raised by the object.