편집

다음을 통해 공유


NSTextStorage Class

Definition

A subclass of NSMutableAttributedString that supports Core Text layout management.

[Foundation.Register("NSTextStorage", true)]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 7, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public class NSTextStorage : Foundation.NSMutableAttributedString
type NSTextStorage = class
    inherit NSMutableAttributedString
Inheritance
Attributes

Remarks

iOS 7 introduced "Text Kit," a broad set of APIs and modifications of existing classes, built on N: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 AddAttribute(NSString, NSObject, NSRange) or M:Foundation.NSMutableAttributedString.AddAttributes*. The key addition to NSTextStorage is that it maintains references to one or more NSLayoutManagers (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 (LowLevelValue and LowLevelGetAttributes(nint, NSRange)) and two from NSMutableAttributedString (LowLevelSetAttributes(IntPtr, NSRange) and 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.

Constructors

NSTextStorage()

Default constructor, initializes a new instance of this class.

NSTextStorage(IntPtr)

A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

NSTextStorage(NSCoder)

A constructor that initializes the object from the data stored in the unarchiver object.

NSTextStorage(NSObjectFlag)

Constructor to call on derived classes to skip initialization and merely allocate the object.

Properties

ChangeInLength

The change in length for the pending changes.

Class (Inherited from NSObject)
ClassHandle

The handle for this class.

ContainsAttachments (Inherited from NSAttributedString)
DebugDescription

A developer-meaningful description of this object.

(Inherited from NSObject)
Delegate

An instance of the UIKit.INSTextStorageDelegate model class which acts as the class delegate.

Description

Description of the object, the Objective-C version of ToString.

(Inherited from NSObject)
EditedMask

The kinds of edits pending for this NSTextStorage.

EditedRange

The range in this NSTextStorage in which pending changes have been made.

FixesAttributesLazily

Whether this NSTextStorage fixes attributes lazily. Read-only.

Handle

Handle (pointer) to the unmanaged object representation.

(Inherited from NSObject)
IsDirectBinding (Inherited from NSObject)
IsProxy (Inherited from NSObject)
LayoutManagers

The NSLayoutManagers associated with this NSTextStorage. Read-only.

Length

The number of characters in this string.

(Inherited from NSAttributedString)
LowLevelValue

Low-level version of the Value property, returns a handle to the underlying Objective-C NSString.

(Inherited from NSAttributedString)
MutableString (Inherited from NSMutableAttributedString)
RetainCount

Returns the current Objective-C retain count for the object.

(Inherited from NSObject)
Self (Inherited from NSObject)
Size (Inherited from NSAttributedString)
Superclass (Inherited from NSObject)
SuperHandle

Handle used to represent the methods in the base class for this NSObject.

(Inherited from NSObject)
Value

Contents of the object as a string.

(Inherited from NSAttributedString)
WeakDelegate

An object that can respond to the delegate protocol for this type

WritableTypeIdentifiersForItemProvider (Inherited from NSAttributedString)
Zone (Inherited from NSObject)

Methods

AddAttribute(NSString, NSObject, NSRange)

Adds an attribute and its value to the specified range of characters in the string.

(Inherited from NSMutableAttributedString)
AddAttributes(CTStringAttributes, NSRange)

Adds an attribute and its value to the specified range of characters in the string.

(Inherited from NSMutableAttributedString)
AddAttributes(NSDictionary, NSRange)

Adds the specified attributes in the dictionary to the specified range of characters in the string.

(Inherited from NSMutableAttributedString)
AddAttributes(NSStringAttributes, NSRange) (Inherited from NSMutableAttributedString)
AddAttributes(UIStringAttributes, NSRange) (Inherited from NSMutableAttributedString)
AddLayoutManager(NSLayoutManager)

Adds an NSLayoutManager to this NSTextStorage.

AddObserver(NSObject, NSString, NSKeyValueObservingOptions, IntPtr)

Registers an object for being observed externally (using NSString keyPath).   Observed changes are dispatched to the observer’s object ObserveValue(NSString, NSObject, NSDictionary, IntPtr) method.

(Inherited from NSObject)
AddObserver(NSObject, String, NSKeyValueObservingOptions, IntPtr)

Registers an object for being observed externally (using string keyPath).   Observed changes are dispatched to the observer’s object ObserveValue(NSString, NSObject, NSDictionary, IntPtr) method.

(Inherited from NSObject)
AddObserver(NSString, NSKeyValueObservingOptions, Action<NSObservedChange>)

Registers an object for being observed externally using an arbitrary method.

(Inherited from NSObject)
AddObserver(String, NSKeyValueObservingOptions, Action<NSObservedChange>)

Registers an object for being observed externally using an arbitrary method.

(Inherited from NSObject)
Append(NSAttributedString, Object[]) (Inherited from NSMutableAttributedString)
Append(NSAttributedString)

Appends an attributed string to this string.

(Inherited from NSMutableAttributedString)
AwakeFromNib()

Called after the object has been loaded from the nib file. Overriders must call base.AwakeFromNib().

(Inherited from NSObject)
BeginEditing()

Marks the beginning of changes.

(Inherited from NSMutableAttributedString)
BeginInvokeOnMainThread(Action) (Inherited from NSObject)
BeginInvokeOnMainThread(Selector, NSObject)

Invokes asynchrously the specified code on the main UI thread.

(Inherited from NSObject)
Bind(NSString, NSObject, String, NSDictionary) (Inherited from NSObject)
Bind(String, NSObject, String, NSDictionary)
Obsolete.
(Inherited from NSObject)
BindingInfo(String)
Obsolete.
(Inherited from NSObject)
BindingOptionDescriptions(String)
Obsolete.
(Inherited from NSObject)
BindingValueClass(String)
Obsolete.
(Inherited from NSObject)
BoundingRectWithSize(CGSize, NSStringDrawingOptions) (Inherited from NSAttributedString)
CommitEditing() (Inherited from NSObject)
CommitEditing(NSObject, Selector, IntPtr) (Inherited from NSObject)
ConformsToProtocol(IntPtr)

Invoked to determine if this object implements the specified protocol.

(Inherited from NSObject)
ContainsAttachmentsInRange(NSRange) (Inherited from NSAttributedString)
Copy()

Performs a copy of the underlying Objective-C object.

(Inherited from NSObject)
Copy(NSZone)

Performs a copy of the underlying Objective-C object.

(Inherited from NSAttributedString)
DangerousAutorelease() (Inherited from NSObject)
DangerousRelease() (Inherited from NSObject)
DangerousRetain() (Inherited from NSObject)
DeleteRange(NSRange)

Removes the characters in the specified range.

(Inherited from NSMutableAttributedString)
DidChange(NSKeyValueChange, NSIndexSet, NSString)

Indicates a change occurred to the indexes for a to-many relationship.

(Inherited from NSObject)
DidChange(NSString, NSKeyValueSetMutationKind, NSSet) (Inherited from NSObject)
DidChangeValue(String)

Indicates that a change occurred on the specified key.

(Inherited from NSObject)
Dispose()

Releases the resources used by the NSObject object.

(Inherited from NSObject)
Dispose(Boolean)

Releases the resources used by the NSTextStorage object.

DoesNotRecognizeSelector(Selector)

Indicates that this object does not recognize the specified selector.

(Inherited from NSObject)
DoubleClick(nuint) (Inherited from NSAttributedString)
DrawString(CGPoint)

Draws the string at the specified point.

(Inherited from NSAttributedString)
DrawString(CGRect, NSStringDrawingOptions, NSStringDrawingContext) (Inherited from NSAttributedString)
DrawString(CGRect, NSStringDrawingOptions) (Inherited from NSAttributedString)
DrawString(CGRect) (Inherited from NSAttributedString)
Edited(NSTextStorageEditActions, NSRange, nint)

Indicates a change.

EncodeTo(NSCoder)

Encodes the state of the object on the provided encoder

(Inherited from NSAttributedString)
EndEditing()

Marks the end of changes.

(Inherited from NSMutableAttributedString)
EnsureAttributesAreFixed(NSRange)

Ensures that attributes have been fixed in the given range.

EnumerateAttribute(NSString, NSRange, NSAttributedStringEnumeration, NSAttributedStringCallback)

Applies the callback to the specified attribute in the specified range.

(Inherited from NSAttributedString)
EnumerateAttributes(NSRange, NSAttributedStringEnumeration, NSAttributedRangeCallback)

Applies the callback to all the attributes in the specified range.

(Inherited from NSAttributedString)
Equals(NSObject) (Inherited from NSObject)
Equals(Object) (Inherited from NSObject)
ExposedBindings() (Inherited from NSObject)
GetAppKitAttributes(nint, NSRange, NSRange) (Inherited from NSAttributedString)
GetAppKitAttributes(nint, NSRange) (Inherited from NSAttributedString)
GetAttribute(String, nint, NSRange, NSRange) (Inherited from NSAttributedString)
GetAttribute(String, nint, NSRange) (Inherited from NSAttributedString)
GetAttributes(nint, NSRange, NSRange) (Inherited from NSAttributedString)
GetAttributes(nint, NSRange) (Inherited from NSAttributedString)
GetBindingInfo(NSString) (Inherited from NSObject)
GetBindingOptionDescriptions(NSString) (Inherited from NSObject)
GetBindingValueClass(NSString) (Inherited from NSObject)
GetBoundingRect(CGSize, NSStringDrawingOptions, NSStringDrawingContext) (Inherited from NSAttributedString)
GetCoreTextAttributes(nint, NSRange, NSRange) (Inherited from NSAttributedString)
GetCoreTextAttributes(nint, NSRange) (Inherited from NSAttributedString)
GetData(NSRange, NSAttributedStringDocumentAttributes, NSError) (Inherited from NSAttributedString)
GetData(NSRange, NSDictionary, NSError) (Inherited from NSAttributedString)
GetDataFromRange(NSRange, NSAttributedStringDocumentAttributes, NSError) (Inherited from NSAttributedString)
GetDataFromRange(NSRange, NSDictionary, NSError)

d|To be added.

(Inherited from NSAttributedString)
GetDictionaryOfValuesFromKeys(NSString[])

Retrieves the values of the specified keys.

(Inherited from NSObject)
GetDocFormat(NSRange, NSAttributedStringDocumentAttributes) (Inherited from NSAttributedString)
GetDocFormat(NSRange, NSDictionary) (Inherited from NSAttributedString)
GetFileWrapper(NSRange, NSAttributedStringDocumentAttributes, NSError) (Inherited from NSAttributedString)
GetFileWrapper(NSRange, NSDictionary, NSError) (Inherited from NSAttributedString)
GetFileWrapperFromRange(NSRange, NSAttributedStringDocumentAttributes, NSError) (Inherited from NSAttributedString)
GetFileWrapperFromRange(NSRange, NSDictionary, NSError) (Inherited from NSAttributedString)
GetFontAttributes(NSRange) (Inherited from NSAttributedString)
GetHashCode()

Generates a hash code for the current instance.

(Inherited from NSObject)
GetItemNumber(NSTextList, nuint) (Inherited from NSAttributedString)
GetItemProviderVisibilityForTypeIdentifier(String) (Inherited from NSAttributedString)
GetLineBreak(nuint, NSRange) (Inherited from NSAttributedString)
GetLineBreakByHyphenating(nuint, NSRange) (Inherited from NSAttributedString)
GetMethodForSelector(Selector) (Inherited from NSObject)
GetNativeField(String)
Obsolete.
(Inherited from NSObject)
GetNativeHash() (Inherited from NSObject)
GetNextWord(nuint, Boolean) (Inherited from NSAttributedString)
GetPasteboardPropertyListForType(String) (Inherited from NSAttributedString)
GetRange(NSTextBlock, nuint) (Inherited from NSAttributedString)
GetRange(NSTextList, nuint) (Inherited from NSAttributedString)
GetRange(NSTextTable, nuint) (Inherited from NSAttributedString)
GetRtf(NSRange, NSAttributedStringDocumentAttributes) (Inherited from NSAttributedString)
GetRtf(NSRange, NSDictionary) (Inherited from NSAttributedString)
GetRtfd(NSRange, NSAttributedStringDocumentAttributes) (Inherited from NSAttributedString)
GetRtfd(NSRange, NSDictionary) (Inherited from NSAttributedString)
GetRtfdFileWrapper(NSRange, NSAttributedStringDocumentAttributes) (Inherited from NSAttributedString)
GetRtfdFileWrapper(NSRange, NSDictionary) (Inherited from NSAttributedString)
GetRulerAttributes(NSRange) (Inherited from NSAttributedString)
GetUIKitAttributes(nint, NSRange, NSRange) (Inherited from NSAttributedString)
GetUIKitAttributes(nint, NSRange) (Inherited from NSAttributedString)
GetUrl(nuint, NSRange) (Inherited from NSAttributedString)
GetWritableTypesForPasteboard(NSPasteboard) (Inherited from NSAttributedString)
GetWritingOptionsForType(String, NSPasteboard) (Inherited from NSAttributedString)
Init() (Inherited from NSObject)
InitializeHandle(IntPtr, String) (Inherited from NSObject)
InitializeHandle(IntPtr) (Inherited from NSObject)
InitWithPasteboardPropertyList(NSObject, String)
Obsolete.
(Inherited from NSAttributedString)
Insert(NSAttributedString, nint)

Inserts an attributed string into the current string.

(Inherited from NSMutableAttributedString)
InvalidateAttributes(NSRange)

Invalidates attributes in the specified range.

Invoke(Action, Double) (Inherited from NSObject)
Invoke(Action, TimeSpan) (Inherited from NSObject)
InvokeOnMainThread(Action) (Inherited from NSObject)
InvokeOnMainThread(Selector, NSObject)

Invokes synchrously the specified code on the main UI thread.

(Inherited from NSObject)
IsEqual(NSAttributedString)

Whether this is equal to the other string.

(Inherited from NSAttributedString)
IsEqual(NSObject) (Inherited from NSObject)
IsKindOfClass(Class) (Inherited from NSObject)
IsMemberOfClass(Class) (Inherited from NSObject)
LoadData(String, Action<NSData,NSError>)

Implement this method to customize the loading of data by an NSItemProvider.

(Inherited from NSAttributedString)
LoadDataAsync(String, NSProgress) (Inherited from NSAttributedString)
LoadDataAsync(String) (Inherited from NSAttributedString)
LowLevelGetAttributes(nint, NSRange)

Low-level version that provides an NSDictionary for the attributes in the specified range.

(Inherited from NSAttributedString)
LowLevelSetAttributes(IntPtr, NSRange)

Low-level version of SetAttributes for high throughput attribute setting.

(Inherited from NSMutableAttributedString)
MarkDirty()

Promotes a regular peer object (IsDirectBinding is true) into a toggleref object.

(Inherited from NSObject)
MutableCopy()

Creates a mutable copy of the specified NSObject.

(Inherited from NSObject)
MutableCopy(NSZone)

Performs a copy of the underlying Objective-C object.

(Inherited from NSAttributedString)
ObjectDidEndEditing(NSObject) (Inherited from NSObject)
ObserveValue(NSString, NSObject, NSDictionary, IntPtr)

Indicates that the value at the specified keyPath relative to this object has changed.

(Inherited from NSObject)
PerformSelector(Selector, NSObject, Double, NSString[]) (Inherited from NSObject)
PerformSelector(Selector, NSObject, Double)

Invokes the selector on the current instance and if the obj is not null, it passes this as its single parameter.

(Inherited from NSObject)
PerformSelector(Selector, NSObject, NSObject) (Inherited from NSObject)
PerformSelector(Selector, NSObject) (Inherited from NSObject)
PerformSelector(Selector, NSThread, NSObject, Boolean, NSString[]) (Inherited from NSObject)
PerformSelector(Selector, NSThread, NSObject, Boolean) (Inherited from NSObject)
PerformSelector(Selector) (Inherited from NSObject)
PrepareForInterfaceBuilder() (Inherited from NSObject)
ProcessEditing()

Activates post-editing operations.

ReadFromData(NSData, NSAttributedStringDocumentAttributes, NSDictionary, NSError) (Inherited from NSMutableAttributedString)
ReadFromData(NSData, NSDictionary, NSDictionary, NSError) (Inherited from NSMutableAttributedString)
ReadFromFile(NSUrl, NSAttributedStringDocumentAttributes, NSDictionary, NSError)

Developers should not use this deprecated method. Developers should use 'ReadFromUrl' instead.

(Inherited from NSMutableAttributedString)
ReadFromFile(NSUrl, NSDictionary, NSDictionary, NSError) (Inherited from NSMutableAttributedString)
ReadFromUrl(NSUrl, NSAttributedStringDocumentAttributes, NSDictionary<NSString,NSObject>, NSError) (Inherited from NSMutableAttributedString)
ReadFromUrl(NSUrl, NSDictionary<NSString,NSObject>, NSDictionary<NSString,NSObject>, NSError) (Inherited from NSMutableAttributedString)
RemoveAttribute(String, NSRange)

Removes the specified attribute from the range of characters

(Inherited from NSMutableAttributedString)
RemoveLayoutManager(NSLayoutManager)

Removes an NSLayoutManager from this NSTextStorage's LayoutManagers collection.

RemoveObserver(NSObject, NSString, IntPtr)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath and context.

(Inherited from NSObject)
RemoveObserver(NSObject, NSString)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath.

(Inherited from NSObject)
RemoveObserver(NSObject, String, IntPtr)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath and context.

(Inherited from NSObject)
RemoveObserver(NSObject, String)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath.

(Inherited from NSObject)
Replace(NSRange, NSAttributedString)

Replaces the specified range of characters with an attributed string.

(Inherited from NSMutableAttributedString)
Replace(NSRange, String)

Replaces the specified range of characters with an attributed string.

(Inherited from NSMutableAttributedString)
RespondsToSelector(Selector)

Whether this object recognizes the specified selector.

(Inherited from NSObject)
SetAttributes(CTStringAttributes, NSRange)

Sets the attributes for the specified ranges. Any previous attributes in that range are replaces with the new values.

(Inherited from NSMutableAttributedString)
SetAttributes(NSDictionary, NSRange)

Sets the attributes for the specified ranges. Any previous attributes in that range are replaces with the new values.

(Inherited from NSMutableAttributedString)
SetAttributes(UIStringAttributes, NSRange) (Inherited from NSMutableAttributedString)
SetNativeField(String, NSObject)
Obsolete.
(Inherited from NSObject)
SetNilValueForKey(NSString)

Sets the value of the specified key to null.

(Inherited from NSObject)
SetString(NSAttributedString)

Sets the contents of this NSMutableAttributedString to the value specified.

(Inherited from NSMutableAttributedString)
SetValueForKey(NSObject, NSString)

Sets the value of the property specified by the key to the specified value.

(Inherited from NSObject)
SetValueForKeyPath(IntPtr, NSString)

A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

(Inherited from NSObject)
SetValueForKeyPath(NSObject, NSString)

Sets the value of a property that can be reached using a keypath.

(Inherited from NSObject)
SetValueForUndefinedKey(NSObject, NSString)

Indicates an attempt to write a value to an undefined key. If not overridden, raises an NSUndefinedKeyException.

(Inherited from NSObject)
SetValuesForKeysWithDictionary(NSDictionary)

Sets the values of this NSObject to those in the specified dictionary.

(Inherited from NSObject)
Substring(nint, nint) (Inherited from NSAttributedString)
ToString()

Returns a string representation of the value of the current instance.

(Inherited from NSObject)
Unbind(NSString) (Inherited from NSObject)
Unbind(String)
Obsolete.
(Inherited from NSObject)
ValueForKey(NSString)

Returns the value of the property associated with the specified key.

(Inherited from NSObject)
ValueForKeyPath(NSString)

Returns the value of a property that can be reached using a keypath.

(Inherited from NSObject)
ValueForUndefinedKey(NSString)

Indicates an attempt to read a value of an undefined key. If not overridden, raises an NSUndefinedKeyException.

(Inherited from NSObject)
WillChange(NSKeyValueChange, NSIndexSet, NSString)

Indicates that the values of the specified indices in the specified key are about to change.

(Inherited from NSObject)
WillChange(NSString, NSKeyValueSetMutationKind, NSSet) (Inherited from NSObject)
WillChangeValue(String)

Indicates that the value of the specified key is about to change.

(Inherited from NSObject)

Events

DidProcessEditing

Event raised by the object.

WillProcessEditing

Event raised by the object.

Extension Methods

GetDebugDescription(INSObjectProtocol)
ContainsAttachments(NSAttributedString, NSRange)

Returns true if the current NSAttributedString contains attachments in the specified range.

FixAttributesInRange(NSMutableAttributedString, NSRange)

Cleans up inconsistencies that can accumulate over many edits.

GetAccessibilityCustomRotors(NSObject)

Gets the array of UIAccessibilityCustomRotor objects appropriate for this object.

SetAccessibilityCustomRotors(NSObject, UIAccessibilityCustomRotor[])

Sets the array of UIAccessibilityCustomRotor objects appropriate for this object.

Applies to

See also