uiwebview

Swift Retrieve HTML data from Webview

大城市里の小女人 提交于 2019-12-06 15:25:08
问题 I am trying to obtain the data within the header of a web page that is being displayed in a UIWebView. How do I get the raw (unformatted) HTML string from the UIWebView? Also, I'm using iOS 9. My question is similar to Reading HTML content from a UIWebView , but this post is from 6 years ago. 回答1: From the top answer on the question you linked: NSString *html = [yourWebView stringByEvaluatingJavaScriptFromString: @"document.body.innerHTML"]; would translate into Swift: let html = yourWebView

UIWebView scaling page so that there is no need for horizontal scrolling

匆匆过客 提交于 2019-12-06 15:12:04
问题 Is there a way to scale a web page in a UIWebView that maintains the aspect ratio but alleviates the need to scroll horizontally to read an article, for example. Vertical scrolling is fine, I just don't want the user to have to constantly be scrolling back and forth horizontally to read each line of the article. Thanks! Edit: the code I'm using to create the view _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, [[self view] frame].size.width, [[self view] frame].size.height)]; [

How can I perform Paging in UIWebView?

我的梦境 提交于 2019-12-06 15:11:08
I have ten local HTML files in my Resource folder and I want to performing paging effect like ScrollView and ImageView so please help me how I can do that. I have displayed HTML page in webView , but i don't have any more ideas. My code is (but it's for only One page): arrHtmlPage=[[NSMutableArray alloc] initWithObjects:@"2",@"3",@"5",@"6",@"8",@"9",@"11",@"13",nil]; NSBundle *bundle = [NSBundle mainBundle]; NSString *htmlTemplateLink = [bundle pathForResource:@"2" ofType:@"htm"]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:htmlTemplateLink]]; wview=[[UIWebView

self.viewController.webView stringByEvaluatingJavaScriptFromString does not work

人盡茶涼 提交于 2019-12-06 15:09:15
NSString* jsString = [NSString stringWithFormat:@"alert('ok');"];[self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString]; I wrote it in cordova appdelegate.m! On cordova-ios@3.x you should be able to do: [self.webView stringByEvaluatingJavaScriptFromString:jsString]; On cordova-ios@4+ you will need to cast the Webview class as it also supports WKWebView: if ([self.webView isKindOfClass:[UIWebView class]]) { [(UIWebView*)self.webView stringByEvaluatingJavaScriptFromString:jsString]; } May want to try NSString* jsString = [NSString stringWithString:@"alert('ok');"];[self

Calculate UIWebview height in UITableViewCell with twitter embed tweet

笑着哭i 提交于 2019-12-06 15:05:42
I'm loading an html to a webview, that can contain embed links to twitter, vimeo, youtube, or just plain simple html. Just for test purpose, i've created a simple view using the same way i'm calculating the height, and i have a table view the is dependent of the height calculated to show the webview correctly. The problem is that calculated heights are wrong, so embed html is not displayed in correctly. This are the relevant prats of my code: -> This loads html string in dummy webview, the only purpose it to calculate correct height, the dummy view is used to trigger load of html: - (void)

Jump through search results in UIWebView with Javascript

喜夏-厌秋 提交于 2019-12-06 15:05:20
I have set up a search in uiwebview with javascript that works great, but I want to be able to jump to the next found word in the search results. I have succeeded in geting the view to scroll to the first instance by using this code: if (uiWebview_SearchResultCount == 1) { var desiredHeight = span.offsetTop - 140; window.scrollTo(0,desiredHeight); } How can I get this searchresultcount to update to the next found result(say 2, 3, 4, 5, ect...) when user presses button in app?? Thanks in advance. I was able to do basically the same thing with this javascript in the webview: <script type="text

WKWebView gives SecurityError when bundling html and javascript with app

独自空忆成欢 提交于 2019-12-06 15:02:30
We are trying to migrate a hybrid app from UIWebView (iOS < 8) to WKWebView (iOS 8), but we are getting SecurityErrors when trying to store stuff using the DOM WebDatabase API (i.e. 'web sql databases'). The following throws an error if the index.html has been loaded from a bundled file with the app // throws SecurityError: DOM Exception 18 var db = openDatabase('mydb', '1.0', 'key value store', 1); The same code works fine with UIWebView. I can fallback to using Local Storage for some reason, but using WebSQL databases is a no go. I can only speculate that this has something to do with the

load local image into UIWebView

半腔热情 提交于 2019-12-06 14:42:49
问题 I want to take a screenshot and then send to webview a local path for it, so it will show it. I know that webview could take images from NSBundle but this screenshots are created dynamically - can I add something to it by code? I was trying it like this: UIGraphicsBeginImageContext( webView.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSString *file = @"myfile.png";

Prevent Phone Number recognition on JqueryMobile

断了今生、忘了曾经 提交于 2019-12-06 14:19:13
I have this problem using Jquery Mobile. The issue was I have a date value of "12/6/1999" that is displayed on a label. Now JQuery Mobile converted it to a link because it is recognize as a phone number. I'm not very sure if it's jquery that does that or the iPhone. So, my first approach was I'm looking for a way to prevent jquery mobile to recognize phone numbers. Is there a way to do it? If it's iPhone that does it, is there a way that I can disable it? Your help is greatly appreciated. You could try <meta name = "format-detection" content = "telephone=no"> This will tell safari to not

Autorotation, UIWebView and UITabBarController

痴心易碎 提交于 2019-12-06 13:58:41
I have the following View hierarchy: UITabBarController | UINavigationController | | | UIViewController (only supports Portrait rotation) | UINavigationController | | | UIViewController (only supports Portrait rotation) | UINavigationController | | | UIViewController (only supports Portrait rotation) | | | UIViewController (has UIWebView with movie in it) | UINavigationController | UIViewController (only supports Portrait rotation) The issue is now that when I display the UIWebView with the movie in it and the user presses "play" the fullscreen media player opens as expected. However, I am not