uiwebview

How to get position of an element in UIWebView?

a 夏天 提交于 2019-12-02 20:40:23
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. Because having to include jQuery just for this sucks: - (CGRect)positionOfElementWithId:(NSString *)elementID { NSString *js = @"function f(){ var r = document.getElementById('%@').getBoundingClientRect(); return '{{'+r

Getting rid of link-click “flash” indicator in iOs UIWebView

删除回忆录丶 提交于 2019-12-02 20:37:54
My iPad app uses a lot of UIWeb views to display content. The user clicks small images with links to pull up a smaller view with additional content. When you tap a link in a UIWebview, the link highlights gray for a moment to indicate the click. In the case of links in an in an image, the whole image rectangle flashes gray for a moment, and it's pretty ugly. Is there any way to disable this behavior? Sure, use the -webkit-tap-highlight-color CSS property: <style type="text/css"> a { -webkit-tap-highlight-color:rgba(0,0,0,0); } </style> 来源: https://stackoverflow.com/questions/3772477/getting

Unreproducible webcore crashes

风流意气都作罢 提交于 2019-12-02 20:36:56
I've got an iPad app that's in the App Store for around three months now and I've been receiving some weird crash reports that I can't figure out. These are not that frequent, got around 15-20 instances since the launch but still frequent enough to actually bug me. The crashes are slightly different (see stack traces below) but since they are related to WebCore I'm guessing they have to do with the usage of the UIWebView in the app and might have a common cause, though I'm not 100% positive. The deployment target of the app is iOS 6.0 but crashes appear on iPad 2, iPad 3 and iPad Mini,

setStart and setEnd throwing error when trying to programmatically select text in UIWebView

杀马特。学长 韩版系。学妹 提交于 2019-12-02 19:57:20
问题 Here is some HTML that I am working with in my UIWebView: <div id = "1"> <span style = "background-color:red"> <a href = "10&20"> This is a link </a> </span> </div> Once the link is tapped, I want to programmatically select the link text in the UIWebView (so "This is a link" would now be highlighted with the blue iOS text selection tool). This is why I am sending some range information in the href of the a tag. This is the call I am using to try and make this programmatic selection: //set

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

爱⌒轻易说出口 提交于 2019-12-02 19:51:51
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 sharedPrintController]; //pic.delegate = self; UIPrintInfo *printInfo = [UIPrintInfo printInfo]; printInfo

Send parameters to a local file in a UIWebView

萝らか妹 提交于 2019-12-02 19:36:05
I'm working on a native iPhone app. I am able to load a local file index.html into a UIWebView: [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]]; The web loads fine. Now, I would like to load the web with some parameters, in the same way one types this in the browser: URL?var1=myValue&var2=myValue2 So I can get those values inside the javascript of the html file. Is there any way to send parameters to a local html file? Thanks! The best and really working answer, only in objC (remember to

Activity indicator with custom image

独自空忆成欢 提交于 2019-12-02 19:35:51
I am loading a UIWebView and in the meantime I wan't to show a blank page with this activity indicator spinning (siri activity indicator). From what I have understand you can not change the image, but can't I use that image and create an animation with it rotating 360° and looping? Or will that drain the battery? something like this?: - (void)webViewDidStartLoad:(UIWebView *)webView { //set up animation [self.view addSubview:self.loadingImage]; //start animation } - (void)webViewDidFinishLoad:(UIWebView *)webView { //stop animation [self.loadingImage removeFromSuperview]; } What should I do?

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

和自甴很熟 提交于 2019-12-02 19:20:16
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. notyce You can easily load webpages like this: NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString:@"http://stackoverflow.com"]] ; [webView loadRequest:request] ; For local files it depends on the location of the file on your device: For files in your main-bundle (= your project), you can

Black bar appearing in UIWebview when device orientation changes

北战南征 提交于 2019-12-02 19:17:01
I have a UIWebView that I am loading onto another view, everthing looks fine in portrait or landscape when rotating, however when I am in portrait and I zoom in slightly with pinch or double tap when I rotate from portrait to landscape the view dosnt fill completely with the uiwebview, there are about 10pxls on the right that turn black as outlined in this screen shot. if you look carefully you can see the outline of the scroll indicator in the black, which segests this is part of the uiwebview?? if so then why dose it turn black in this area. Also heres another screen shot of the webview

How to clean the content of UIWebView without loading an empty page?

别来无恙 提交于 2019-12-02 19:09:24
I need to clean the content of UIWebView(in order to reuse it), but I have some authentication handling code in its delegate methods, so I do not want to load an empty page like about:blank to clean it, as it will trigger my authentication handling code. So is there a way for doing this? (also, by reusing it, I need to put a spinner on top of the web view, and when it loads another page, I don't want the user see the previous loaded page content, so that's why I need to clean it) Thanks! You can just use this line of code : [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString