【问题标题】:Formatting and Bullets in a TextBox in iOS5iOS5 中文本框中的格式和项目符号
【发布时间】:2012-07-06 16:13:10
【问题描述】:

有谁知道如何在 iOS 5、XCode 4.3 中插入​​项目符号并在文本框中进行一些格式化,可能在 web 视图中(如下面的打印屏幕所示)?

【问题讨论】:

    标签: ios5 webview formatting xcode4.3


    【解决方案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];
    

    两个结果都进入以下列表:

    • 堆栈
    • 溢出

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-28
      • 1970-01-01
      • 1970-01-01
      • 2020-08-27
      • 2018-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多