Search code examples
iosios6uitextviewtoggleuiresponder

UITextView UIResponderStandardEditActions Text Formatting Toggle State


How do I determine the current state of the UIResponderStandardEditActions for text formatting? For example, if I do the following:

[textView toggleBoldface:nil];

How do I query the textView to find out if the state of bold is now on or off? This is for just a cursor with no selection (i.e. range length is 0). As such, enumerateAttribute doesn't seem to work.

Thank you.


Solution

  • It appears the typingAttributes property (available in iOS 6) will log the attributes that will be applied to new text typed by the user, even with a selection length of 0. Thus revealing what the state of formatting options such as bold will be.

    NSLog(@"textViewFormatting options: %@", [[self noteTextView] typingAttributes]);