简体   繁体   English

在UIWebView中加载HTML内容-iOS

[英]Load html content in UIWebView - iOS

I am loading html content in UIWebview (iPhone6) and the content has actionable buttons. 我正在UIWebview(iPhone6)中加载html内容,并且该内容具有可操作的按钮。 Upon pressing one of the buttons a pop up shows up in the middle of the content (content is approximately 6-7 pages long). 按下其中一个按钮后,内容中间会弹出一个对话框(内容长约6-7页)。 As a result, user is unable to see the popup as she is on the first screen. 结果,用户无法在第一个屏幕上看到弹出窗口。 Earlier, I thought it was content's issue, but on android, the pop up comes on the middle of the first page. 早些时候,我认为这是内容的问题,但是在android上,弹出式窗口出现在首页的中间。

-(void) loadScorm {

NSString *scormUrl = self.content.media.scormUrl;
scormUrl = [NSString stringWithFormat:@"%@%@", @"https:" , scormUrl];
NSURL *url = [NSURL URLWithString:scormUrl];
NSString *body;
body = //constructed body

NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];
[request setHTTPMethod: @"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[body dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
self.webView.scalesPageToFit = YES;
[self.webView loadRequest:request];
self.webView.frame = self.webViewContainer.frame;
}

I also read that javascript for UIWebView is enabled by default. 我还读到UIWebView的javascript默认是启用的。 What am I missing? 我想念什么? Any pointers would be appreciated. 任何指针将不胜感激。

PS: Can't share the screenshot as the content is classified. PS:由于内容分类,无法共享屏幕截图。

How you create your UIWebView via Code or IBOutlet. 如何通过代码或IBOutlet创建UIWebView。

If you are created your webView via IBOutlet then you have to check some webView property in Storyboard like 如果通过IBOutlet创建了webView,则必须在Storyboard中检查一些webView属性,例如

Then your webView will take Events. 然后,您的webView将执行事件。

我猜你的财产就是这样

检查事件,链接,地址,电话号码

And if you are created your UIWebView via code then write this code 如果您通过代码创建了UIWebView,请编写以下代码

[your_webView_Object setDataDetectorTypes: UIDataDetectorTypeAll];
  [webview loadHTMLString: [NSString stringWithFormat:@"<div id ='foo' align='justify' style='font-size:22px; font-family:helvetica; color:#ffffff';>%@<div>",[jsonObject objectForKey:@"msg"]] baseURL:nil];

希望你会发现有用

Apparently, this was an issue from the side of content creator. 显然,这是内容创建者的问题。 The person didn't include the support of Safari and Chrome on iOS platform and hence, these issues. 该人员不包括iOS平台上的Safari和Chrome支持,因此没有这些问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM