1

I want to display and edit superscripts and subscripts my application. In UITextView's documentation it said that you cannot use any kind of formatting that doesn't apply to the whole document. I realize I still have a few options on how to display these formats, I'm not sure what will be the best and I would like some advice.

  1. I can maybe subclass UITextView to achieve that effect, but I'm not too sure how I would do that, and In the documentation it says that you shouldn't subclass it. I also know not to listen to Apple :-D.

  2. I could reinvent the wheel and use core graphics to just put the individual characters were they belong while paying extreme attention to their sizes and placements with respect to the other characters.

I am pretty new so any other ideas would be very much appreciated.

Jordan Medlock
  • 807
  • 1
  • 8
  • 21

2 Answers2

1

Ideally, you want to use an NSAttributedString which supports super/subscripts as well as other "rich text" features. However, UITextView does not support NSAttributedStrings directly.

The thread here discusses your options. The recommendation is to use the OmniUI framework by Omnigroup, which can be found here. I haven't personally used this library, but it looks very promising.

Community
  • 1
  • 1
cocoahero
  • 1,302
  • 9
  • 12
  • Now that iOS 5 features rich text in its emails do you think that that means with iOS 5 UITextView will also be able to include rich text? – Jordan Medlock Oct 21 '11 at 03:57
  • It looks like the default actions are still only copy, cut, and paste. You can always add your own actions though. – cocoahero Oct 21 '11 at 13:21
0

Your easiest option for formatted text is to use HTML, a UIWebView.

David Dunham
  • 8,139
  • 3
  • 28
  • 41