有没有人知道如何插入项目符号并在文本框中进行一些格式化,可能在iOS 5,XCode 4.3中的webview中(如下面的打印屏幕所示)?
答案 0 :(得分:2)
对于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];
两者都会产生以下列表:
- Stack
- 溢出