uiwebview

Create a UIImage by rendering UIWebView on a background thread - iPhone

℡╲_俬逩灬. 提交于 2019-11-28 23:46:10
Does someone know of a way, or has a creative idea as to how to obtain an UIImage that is rendered from a UIWebView? The catch is, that is must be on a background thread. I'll elaborate: I'm trying to obtain the image from multiple UIWebViews every second+-, and display it on screen (iPhone's of course). Because rendering a layer to a CGContext is a CPU consuming job, I wouldn't like to use the main thread, so not to hang the UI. My attempts so far were: I tried to use renderInContext on the webView's layer to the UIGraphicalContext , but the _WebTryThreadLock error crashed the webviews. I

UIWebView disable zooming when scalesPageToFit is ON

血红的双手。 提交于 2019-11-28 23:15:34
Is there any way to disable zooming when Scales page to Fit is ON ?? This works for me: UIScrollView *scrollView = [webView.subviews objectAtIndex:0]; scrollView.delegate = self;//self must be UIScrollViewDelegate - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return nil; } UPDATE: For iOS 5 or higher get scrollView like this: webview.scrollView.delegate = self; Instead of using UIScrollView *scrollView = [webView.subviews objectAtIndex:0]; scrollView.delegate = self;//self must be UIScrollViewDelegate - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {

UIWebView stringByEvaluatingJavaScriptFromString

ぐ巨炮叔叔 提交于 2019-11-28 23:15:25
问题 I'm stuck on getting some pretty basic JS to run in my UIWebView. In the web view's delegate, I have : - (void)webViewDidFinishLoad:(UIWebView *)wView { NSString *someHTML = [wView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('box')[0]"]; NSString *allHTML = [wView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"]; NSLog(@"someHTML: %@", someHTML); NSLog(@"allHTML: %@", allHTML); } but when the method is invoked, someHTML is nil while allHTML

Resize images in UIWebView to viewport size

风流意气都作罢 提交于 2019-11-28 23:04:44
问题 I'm displaying HTML with some images inside a UIWebView in my iPhone App. When the images are wider than the viewport of the iPhone I get horizontal scrollers which I don't want because its mostly about the text not the images. Is there a way to resize images displayed inside the UIWebView according to the width (best: even if the device is rotated)? 回答1: If you want the maximum width to be the width of the webView, use the max-width CSS property. max-width: 100%; width: auto; height: auto;

Why does clearing NSUserDefaults cause EXC_CRASH later when creating a UIWebView?

人走茶凉 提交于 2019-11-28 22:34:40
Before I begin, I should tell you that this only happens in iOS 5.1. Before the most recent update, this had never happened and it still does not happen on any other version. That said, here's what's going on. When a user logs out of my app, one of the things that happens is that all of the NSUserDefaults get deleted. Rather than manually removing every key I might add to the user's defaults, I just completely delete all of the NSUserDefaults , using the method suggested in this SO question : NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; [[NSUserDefaults standardUserDefaults]

How to get HTTP headers

亡梦爱人 提交于 2019-11-28 22:19:36
问题 How do you retrieve all HTTP headers from a NSURLRequest in Objective-C? 回答1: This falls under the easy, but not obvious class of iPhone programming problems. Worthy of a quick post: The headers for an HTTP connection are included in the NSHTTPURLResponse class. If you have an NSHTTPURLResponse variable you can easily get the headers out as a NSDictionary by sending the allHeaderFields message. For synchronous requests — not recommended, because they block — it’s easy to populate an

Dynamically loading javascript files in UIWebView with local cache not working

此生再无相见时 提交于 2019-11-28 22:06:51
I'm trying to write an application which uses a lot of java script inside a UIWebView. And some of this java script is loaded dynamically (with jquery) when it is needed. The index.html and the jquery files are loaded as expected but not the code.js file. The code.js file is request like this (snipped of the java script code from index.html): function require(moduleName,filePath) { var uri = filePath; jQuery.ajax({ type: "GET", url: uri, async: false, dataType: "script", success: function(content) { console.log("Receive content of "+moduleName); }, error: function(XMLHttpRequest, textStatus,

iOS any body knows how to add a proxy to NSURLRequest?

ε祈祈猫儿з 提交于 2019-11-28 21:46:02
问题 I'm setting up a webview but I need to load the content of the webview using a proxy. Any of you knows how can I'm implement the proxy in NSURLRequest? for example: NSString *location=@"http://google.com"; NSURL *url=[NSURL URLWithString:location]; NSURLRequest *request=[NSURLRequest requestWithURL:url]; // some code to set the proxy [self.myWebView loadRequest:request]; I'll really appreciate your help 回答1: Take a look at iOS URL Loading System as well as NSURLProtocol You can write a custom

UIWebView: Can I disable the javascript alert() inside any web page?

点点圈 提交于 2019-11-28 21:26:47
I am using UIWebView to load a URL. Inside the page of that URL, it uses alert("whatever msg") as JavaScript. My UIWebView will pop up a window and show that alert message. Is there a way to disable this kind of popup window or JavaScript alert window? Add this after your web view has loaded its content [MyWebView stringByEvaluatingJavaScriptFromString:@"window.alert=null;"]; You can bind window.alert to another function. So: window.alert = function() { //does nothing so effectively "disables" alert }; Make sure you do this before you call any alerts. The neat thing about this is you can

How to get coordinates (CGRect) for the selected text in UIWebView?

爱⌒轻易说出口 提交于 2019-11-28 21:26:12
I have simple UIWebView with loaded html. I want to show the PopoverView pointed to the selected text. I can get the menuFrame of the UIMenuController and use its rect, but the result isn't as accurate at the corners of the screen as I need. I can calculate the screen size and get menuFrame rect and then I can suppose where the selection may be found, but I want exactly know where is the selected text. Is it generally possible? hwaxxer You can use the javascript function getBoundingClientRect() on the range object of the selected text. This is how I do it: function getRectForSelectedText() {