2012-07-06 23 views

回答

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]; 

兩個結果進以下列表:

  • 堆棧
  • 溢出
相關問題