有谁知道如何插入子弹和做一些格式化的文本框,也许在网页视图中的iOS 5时,Xcode 4.3(如下面的打印屏幕显示)?
Answer 1:
对于UITextView
手动添加点和换行,例如:
NSArray *items = [NSArray arrayWithObjects:@"Stack",@"Overflow",nil];
NSMutableString *formattedString = [[NSMutableString alloc] init ];
for (NSString *item in items) [formattedString appendFormat:@"\u2022 %@\n", item];
theTextViewName.text = formattedString;
对于UIWebView
创建一个无序的HTML
列表,例如:
NSArray *items = [NSArray arrayWithObjects:@"Stack",@"Overflow",nil];
NSMutableString *theSource = [[NSMutableString alloc] init ];
[theSource appendFormat:@"<ul>"];
for (NSString *item in items) [theSource appendFormat:@"<li>%@</li>", item];
[theSource appendFormat:@"</ul>"];
[theWebView loadHTMLString:theSource baseURL:nil];
这两种结果分为以下列表:
- 堆
- 溢出
文章来源: Formatting and Bullets in a TextBox in iOS5