MathJax 和 iPhone Objective C
我正在尝试在我正在构建的 iPhone 应用程序中使用 MathJax。目前,我的 Resources 文件夹中既有 MathJax 也有 MathJax 的解压版本。我的 Resources 文件夹中有一个 html 文件,它是 MathJax 测试文件夹中的 example.html 文件的直接副本。然后我有一个加载视图,当它加载数据到 UIWebView 时。
当视图加载时,它从文件中获取数据,如下所示:
NSString *htmlText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
通过执行以下操作来检索文件路径: `NSString *filePath = [[NSBundle mainBundle] pathForResource:"SSS" ofType:@"html"];
然后,我的资源文件夹中有 MathJax 文件夹,并进行了设置,以便它们列在“复制捆绑资源”而不是“构建阶段中的编译源”下。
一旦我在字符串中包含了 htmlText 。我去加载 UIWebView 中的数据。我按照以下方式执行此操作:
[htmlView loadHTMLString:htmlText baseURL:[[NSBundle mainBundle] resourceURL]];
网页加载到 UIWebView 中,但没有一个 LaTex 能够正确呈现。当我加载 MathJax 文件夹中的sample.html 页面时,它会正确加载,因此我知道我的设置是正确的。任何帮助都会很棒。
谢谢
I am trying to use MathJax in my iPhone app that I am building. I currently have both MathJax and the unpacked version of MathJax in my Resources folder. I have a html file in my Resources folder that is a direct copy of the sample.html file in the MathJax test folder. I then have a view that loads and when it does loads data into a UIWebView.
When the view loads it gets the data from the file like this:
NSString *htmlText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
The File path is retrieved by doing the following: `NSString *filePath = [[NSBundle mainBundle] pathForResource:"SSS" ofType:@"html"];
Then I have the MathJax folders in my resource folders and do have them setup so that they are listed under Copy Bundle Resources not Compile Sources in the Build Phases.
Once I have the htmlText in the string. I go to load the data in the UIWebView. I do this the following way:
[htmlView loadHTMLString:htmlText baseURL:[[NSBundle mainBundle] resourceURL]];
The webpage loads into the UIWebView but none of the LaTex is rendered correctly. When I load the sample.html page within the MathJax folder it loads correctly, so I know that I have that setup right. Any help would be great.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用:
这样相对路径就能正确使用。
Use:
This way relative paths will be used properly.
我添加了一篇关于在本地使用 MathJax v1.1a 的新帖子 此处。 Davide 建议了一些进一步的改进,我还没有时间尝试,但现有的代码应该有助于解决您的问题,希望这会有所帮助。
I have added a new post about using MathJax v1.1a locally here. Davide have suggested some further improvements which I haven't got time to try yet, but the existing code should help with your problem, hope this helps.