【问题标题】:How to display the text of an html file in UIAlertView as a message如何在 UIAlertView 中将 html 文件的文本显示为消息
【发布时间】:2010-07-28 23:18:22
【问题描述】:

我是 iPhone 编程新手.. 我有一个 html 文件..in 有 3 行文本。 我想在消息部分的 alertview 中显示该文本。 为此,我们需要读取 html 并将数据存储在字符串中.. 使用该字符串作为消息... 我对吗..? 然后硬件读取 html 以及如何将其存储在字符串中..?

请帮帮我

谢谢你 ......

NSString *path = [[NSBundle mainBundle] pathForResource:chapter.page ofType:@"html"]; NSString *content = [NSString stringWithContentsOfFile: 路径编码:NSASCIIStringEncoding 错误:NULL];

    UIAlertView *tAlert = [[UIAlertView alloc] initWithTitle:nil message:content delegate:self 
                                           cancelButtonTitle:nil otherButtonTitles:@"CLICK HERE", @"OR CONTINUE", @"OR BACK",nil];


    tAlert.tag=TOSChapter;

    [tAlert show];

    [tAlert release]; 

在它显示html的所有标签...而不是解析html有没有其他方法可以在alertview中显示html的内容..?

谢谢你...

【问题讨论】:

    标签: iphone html uialertview


    【解决方案1】:

    从资源中加载文件:

    NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"yourfile" ofType:@"html"];    
    NSString *content = [NSString stringWithContentsOfFile: htmlPath encoding:NSASCIIStringEncoding error:NULL];
    

    然后,为您的子字符串解析 HTML。

    【讨论】:

    • 感谢 Lou Franco..for 快速响应...我应该解析以获取 html 中的数据...?我不能将此 HTML 文件 ( webView ) 作为子视图添加到 UIAlertView 中吗?还是有其他方法..?再次感谢..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-01
    • 2012-03-19
    • 1970-01-01
    相关资源
    最近更新 更多