Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTML代码显示在应用程序中,而不是xcode中格式化的HTML类型_Html_Objective C_Xcode7 - Fatal编程技术网

HTML代码显示在应用程序中,而不是xcode中格式化的HTML类型

HTML代码显示在应用程序中,而不是xcode中格式化的HTML类型,html,objective-c,xcode7,Html,Objective C,Xcode7,我的应用程序在屏幕上显示html代码。我们使用包含html代码的txt文件。在浏览器上是正确的,在应用程序中以txt文件显示代码 如果在文本视图中显示内容,则可以尝试此操作 NSString *path = [[NSBundle mainBundle] pathForResource:@"YourFileName" ofType:@"txt"]; NSString *content = [NSString stringWithContentsOfFile:path encoding:NS

我的应用程序在屏幕上显示html代码。我们使用包含html代码的txt文件。在浏览器上是正确的,在应用程序中以txt文件显示代码

如果在文本视图中显示内容,则可以尝试此操作

NSString *path = [[NSBundle mainBundle] pathForResource:@"YourFileName" ofType:@"txt"];
    NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
        NSAttributedString *attributedString = [[NSAttributedString alloc]
                  initWithData: [content dataUsingEncoding:NSUnicodeStringEncoding]
                       options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }
            documentAttributes: nil
                         error: nil
        ];
        textView.attributedText = attributedString;

如果在文本视图中显示内容,则可以尝试此操作

NSString *path = [[NSBundle mainBundle] pathForResource:@"YourFileName" ofType:@"txt"];
    NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
        NSAttributedString *attributedString = [[NSAttributedString alloc]
                  initWithData: [content dataUsingEncoding:NSUnicodeStringEncoding]
                       options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }
            documentAttributes: nil
                         error: nil
        ];
        textView.attributedText = attributedString;

你尝试了什么,你想问我们什么…清楚地解释提供关于你正在尝试的平台和你正在使用的框架的信息。很抱歉,我不清楚这个主题。我正在为我的公司使用第三方应用程序。因此,在某些页面上存在数据,这些数据是以html格式从txt文件访问的。在它以有序格式显示之前,现在更新ios9后可以看到完整的HTML代码我猜他们使用的是objective c,我猜s/w是为版本7构建的您已经尝试过的,你想问的是什么?清楚地解释。提供关于你正在尝试的平台和使用的框架的信息。很抱歉,我不清楚这个话题。我正在为我的公司使用第三方应用程序。因此,在某些页面上存在数据,这些数据是以html格式从txt文件访问的。在它以有序格式显示之前,现在在更新ios9后可以看到完整的HTML代码我猜他们使用了objective c,我猜s/w是为版本7构建的