- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 UIWebView 以这样的缅甸字体显示搜索测试
NSString *googleText = @"မြန်မာဘာသာ";
NSString *googleLink = [NSString stringWithFormat:@"http://www.google.com/search?hl=my&lr=lang_my&q=%@",
[[googleText stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"
]
];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:googleLink]]];
这是结果
我没有在我的包中加载 html 文件,所以我不能在 CSS 中使用自定义字体,如 this question或 this one
求助!谢谢!
最佳答案
您可以引用以下工作代码。
NSString *cssString = [[[[@"body { font-family:" stringByAppendingString:centuryGothicRegular] stringByAppendingString:@"; font-size:"] stringByAppendingString:[NSString stringWithFormat:@"%ld",normalFont]] stringByAppendingString:@"}\""] ; //1
NSString *javascriptString = @"var style = document.createElement('style'); style.innerHTML = '%@'; document.head.appendChild(style)"; // 2
NSString *javascriptWithCSSString = [NSString stringWithFormat:javascriptString, cssString]; // 3
NSLog(@"javascriptWithCSSString: \n %@", javascriptWithCSSString);
NSString *loadedContent = [webView stringByEvaluatingJavaScriptFromString:javascriptWithCSSString];
NSLog(@"loaded ocntent: %@", loadedContent);
Font name and size are declare as constant you can change according to your required font
关于ios - 如何在 loadRequest 时向 UIWebView 注入(inject)自定义字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20759188/
我已经阅读了 UIWebView 上的内容,但找不到在调用 loadRequest 时是否可以阻止线程(如 NSURL 可以)的具体答案。我听说有一个特定的 UIWebView 线程,所有 UIWeb
在我的应用程序中,我使用 Webview 根据用户的首选语言加载网站的不同版本。为此使用 WebFrame 的 loadRequest 方法 - [[aWebView mainFrame] loadR
我正在使用UIWebView播放.mp3文件。使用Safari是因为它为我提供了无需附加代码的音频控件,而且我看不到如何使用AVPlayer进行操作。它很简单,除了一个异常(exception),效果
我有 2 个类,UIViewController 类型的 MainViewController 和 UIView 类型的 Foo。 在 MainViewController 中,我实现了一个名为 my
当我使用UIWebView使用loadRequest显示网页时,有时网络不稳定,这是一个耗时的事情,所以我想随意取消loadRequest,怎么办? 最佳答案 只要打电话 [myWebView sto
我创建了一个 UIWebView 并调用了 [webview loadRequest:url]。当 webview 没有父 View /父 View 时,[webview isLoading] 不断返
所以我正在尝试将一个简单的 URL (http://www.google.com) 加载到 WebView 中。我在我正在使用的应用程序中有这个,但将其归结为一个基本应用程序以删除其他变量。我有一个绝
我的目标是在 webView 仍在从服务器获取数据时做一个事件指示器 但我似乎无法找到这样做的方法。我能想到的唯一方法是关闭,但如何关闭? 如果我不添加任何事件指示器,那么它将只是空白屏幕,然后在一段
我的应用程序中有一个 UIWebView, -(void)viewDidLaod{ NSURL *url = [NSURL URLWithString:@"some url string"];
在我的 Controller 中,我调用了 WKWebViewInstance.loadRequest(url)。如果没有可用的互联网,我想在 WKWebView 中加载一条错误消息。 我发现了
如何将以下内容转换为使用“loadRequest”而不是“loadHTMLString”? 我需要添加一个 HTTP header ,我发现的唯一方法是将 loadRequest 与 NSMutabl
我正在尝试使用 UIWebView 在我的应用程序中嵌入网站的移动版本。但是,当我执行以下操作时: NSURL *url = [NSURL URLWithString:webLink]; NSMuta
在我的应用程序中,我尝试使用 WebView(不可见)导航到给定的 URL。但是,加载 Web 内容是异步发生的。对于以后的处理,我需要它来等待所有 Web 内容加载(包括重定向)。 我尝试使用 CF
我有一个 UIWebView,其中的内容被缩放以适合。然后调整 webview 的大小以适应内容(见下文),并按预期工作。 webview 也有一个滑动手势来加载新页面 - 当在 webview 上为
我正在按照 this 创建一个 webView 应用程序教程。我完全按照所有步骤操作,但出现此错误: No visible @interface 'UIView' declares the selec
我正在使用 UIWebView,并且已经在使用 webViewDidFinishLoad: 方法和一个在加载完成后执行的可选 block : -(void)webViewDidFinishLo
我有一个 UIWebView,我想将 SVG 图像加载到其中。该文件的内容是纯 SVG,即 ... .该文件可以很好地加载到普通和移动 Safari 中,也可以使用 loadRequest 在 UIW
我希望能够使用我的 UIWebView loadRequest 方法发送一些额外的 header 。 我试过: NSMutableURLRequest *req = [NSMutableURLRequ
我已经阅读了有关 UIWebView 的很多泄漏问题,但我的情况非常简单,所以我决定提出一个新问题。当我尝试从 WebView loadRequest 方法加载文件时,如果我在 Instruments
我正在尝试使用 Objective C 中的 webView 加载 URL。我尝试了“https://www.tidecleaners.com/cincinati-pricing ”,它适用于所有设备
我是一名优秀的程序员,十分优秀!