uiwebview

How to get position of an element in UIWebView?

删除回忆录丶 提交于 2019-12-03 06:50:53
问题 I have UIWebView loaded with html in my iPad Program. By using -webkit-column-width, I divided the html with several columns. padding: 0px height: 1024px -webkit-column-gap: 0px -webkit-column-width: 768px How can i get the element position(x, y) in webview? The position is on the screen position, not in the html. So y is in range from 0 to height of webview. Thanks in advance. 回答1: Because having to include jQuery just for this sucks: - (CGRect)positionOfElementWithId:(NSString *)elementID {

iOS - display content from an html resource file or remote webpage in a webview

半腔热情 提交于 2019-12-03 06:50:06
问题 I am an iOS newbie. I want to have a function that loads the content from a local html resource file or a webpage depending on what is specified in a constant. How would I go about doing it? For eg, if I pass a file://... to the function or an http://... , it should render accordingly. 回答1: You can easily load webpages like this: NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString:@"http://stackoverflow.com"]] ; [webView loadRequest:request] ; For local files it depends

IOS6 landscape playing embedded youtube video from a uiwebview within an only portrait iPhone app

人盡茶涼 提交于 2019-12-03 06:46:41
I've got an iPhone application with a storyboard,few xib and custom cells. The application is set as a "portrait" as "supported interface orientation" (i mean everything is display like that). In my custom cells, there is Uiwebview that is linked to a youtube embedded video, when i clicked it the video start to playing, but my problem is that they are always playing in "portrait" mode. I've read lots of things that solve this problem but only in ios5. Actually : I can identify when the video start or stop playing. I can identify the device orientation. But i can't (I want) switch (Force)

How Do I Shorten the Pull Distance to Activate the Pull to Refresh Action in iOS 6/7?

霸气de小男生 提交于 2019-12-03 06:29:50
Hey StackOverflow People, I've been trying to figure out this question for some time now but to no avail and I need some help. I have a UITableView close to the bottom of my app and there's not enough screen distance for the user to engage the refresh. Does anybody know how I can shorten the distance it takes to activate the pull to refresh action (via a UIRefreshControl in iOS 6/7) on a UITableView and UIWebView ? Thanks in advance everyone! you can still use refreshControl but with some modifications! add these code to your viewController: var canRefresh = true override func

Making Selection & Adding tag dynamically in JavaScript

巧了我就是萌 提交于 2019-12-03 06:25:51
问题 I need some help about JavaScript on iPhone UIWebView ; I have HTML like below: <html> <head> <title>Example</title> </head> <body> <span>this example for selection <b>from</b> UIWebView</span> </body> </html> I want to make a selection, and add <span> tag with color to the selected text in HTML to write a note just like an e-book reader. This is my JavaScript code to get the selected text: NSString *SelectedString = [NSString stringWithFormat:@"function getSelText()" "{" "var txt = '';" " if

iOS 4.2 - Printing DOC, PPT, XLS, etc. with Apple AirPrint?

走远了吗. 提交于 2019-12-03 06:25:45
问题 I've been playing with iOS 4.2 UIWebView + AirPrint. The problem, however, is that getting the viewPrintFormatter from the UIWebView I'm able to print PDF and images, but not DOC, DOCX, PPT, PPTX, etc. Those files are displayed properly in the UIWebView, but Airprint will print blank pages. Here is my code: [internalWebView loadData:[[printContent objectAtIndex:0] data] MIMEType:mimeType textEncodingName:nil baseURL:nil]; UIPrintInteractionController *pic = [UIPrintInteractionController

Is there a bug with using InnerHTML inside a UIWebView within a native iPhone application?

本秂侑毒 提交于 2019-12-03 06:21:42
I have a fairly large HTML/JS/CSS application that works great when running as a web application with Safari on the iPhone. When running this same application in an UIWebView within a native iPhone application calls within jQuery to create HTML fragments fail silently (ie: $("<div>HELLO WORLD</div>"); will not create the element. I've tracked this down to the following equivalent code snippet in clean jQuery method: var div = document.createElement(“div”); div.innerHTML = “<div>HELLO WORLD</div>” ; When I look at div.outerHTML I see <div>/<div> div.innerHTML returns an empty string. This does

How do I enable horizontal scrolling and disable vertical scrolling in UIWebview?

寵の児 提交于 2019-12-03 06:20:12
My UIWebView should not allow vertical scrolling. However, horizontal scrolling should possible. I have been looking through the documentation, but couldn't find any hints. The following code disables both scrolling directions, but I want to only disable vertical: myWebView.scrollView.scrollEnabled = NO; How do I solve this problem? Enable Horizontal scrolling and disable Vertical scrolling: myWebView.scrollView.delegate = self; [myWebView.scrollView setShowsVerticalScrollIndicator:NO]; -(void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView.contentOffset.y > 0 || scrollView

“SyntaxError: Unexpected EOF” when evaluating JavaScript in iOS UIWebView

天涯浪子 提交于 2019-12-03 06:03:59
I keep getting this error in JavaScript when trying to pass some JSON to a UIWebView : SyntaxError: Unexpected EOF There is no line number or filename available in window.onerror but I've already checked all referenced files, and they are fine. I'm using MonoTouch EvaluateJavaScript method which is equivalent to ObjC stringByEvaluatingJavaScriptFromString: : webView.EvaluateJavascript( "Viewer.init($('#page'), " + json.ToString() + ");" ); It works just fine on “simple” JSON input but breaks at larger objects. What could go wrong? Before passing an NSString to a UIWebView, be sure to escape

Ways to improve UIWebView scrolling performance?

核能气质少年 提交于 2019-12-03 05:59:19
问题 I am building an application that includes a UIWebView containing a large number of images, CSS, embedded video, and JavaScript tap handlers. Scrolling performance is stuttery and I am looking for insight into the most effective ways to improve this. Which if any of the following characteristics lead to laggy UIWebView scrolling? What other factors may be hindering performance? Quantity of images Should I be removing images from the DOM as the user scrolls past them, and adding them back if