格式化和子弹在iOS5中一个TextBox(Formatting and Bullets in a

2019-10-16 22:43发布

有谁知道如何插入子弹和做一些格式化的文本框,也许在网页视图中的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