开发者

How to write long formatted text in a Text View with xCode

开发者 https://www.devze.com 2023-04-07 04:45 出处:网络
I feel strange asking a question about what\'s probably the simplest page in my iPhone app but here it is anyway:

I feel strange asking a question about what's probably the simplest page in my iPhone app but here it is anyway:

I have a controller that a user can invoke to display the rules of the game and some acknowledgment information. I set up a Text View object filling up the whole page in Interface Builder and am wondering what's the best way of entering the text I need.

I can do all of this in the m file but entering large text sections in a programming language 开发者_如何转开发is never fun.

I can also simply overwrite the default "Lorem ipsum dolor..." text in Interface Builder but then my return characters don't seem to be taken into account when I run the app.

Is there a better way to fill my Text View with my own formatted text? And how can I format my text neatly and easily (i.e. make titles in bold, underline some words, etc.)?

Thanks.


There is no way to easily display formatted text in a UITextView. The best approach for this kind of problem is to use a UIWebView and store the text as an HTML file.


Use the NSTextStorage class to store the formatted text in your NSTextView.


Use Core Text Core Text Tutorial for iOS: Making a Magazine App

0

精彩评论

暂无评论...
验证码 换一张
取 消