uiwebview

How to reference HTML anchor?

廉价感情. 提交于 2019-12-01 19:38:53
I'm loading a string of HTML into a UIWebView through loadHTMLString. It produces a very long webpage. Once that string is loaded, I need to navigate to an HTML anchor tag with its "name" attribute set. In the HTML, I might have: //3 pages of text here <a name="go here"></a> lots more text here //another 3 pages of text here I need the webpage to scroll down to "go here" once loaded. The mappings work fine if a user clicks a link inside of the webpage and it loads an external URL. But in this case, I need to initially scroll down an already loaded webpage. I can still execute javascript like

Close UIWebView using javascript:window.close();

血红的双手。 提交于 2019-12-01 18:21:33
问题 The question sounds weird, but here is my case. I have a UIWebView in my UIView ( done by [self.view addSubview:webView]; ) which occupies full screen. It intentionally hides the UIView before the UIWebView clicks on an action javascript:window.close(); . How do I associate JavaScript in UIWebView page to UIView 's action , e.g. [webView removeFromSuperView]; ? 回答1: This is possible: Set the location to something with your own scheme in the url, i.e. document.location.href = "myscheme:/

UIWebView: Error while loading URL

我与影子孤独终老i 提交于 2019-12-01 18:19:18
I am trying to build an RSS reader for the Tom's Hardware website. I have an error when I try to load an URL into an UIWebview from an RSS link. Here'is my code: - (void)viewDidLoad { [super viewDidLoad]; if (self.url != nil) { NSURL *requestUrl = [NSURL URLWithString:self.url]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:requestUrl]; [webView loadRequest:requestObj]; } } The url is setted by the parent controller. When the URL comes directly from the RSS, I have an error in log: [2234:207] Error Domain=WebKitErrorDomain Code=101 UserInfo=0x3a6a240 "Operation could not be completed

iOS UIWebView app opens link in Safari

点点圈 提交于 2019-12-01 18:14:04
I have an iOS app which has only one view and that is UIWebView (It opens the main content of the app). I would like when I make a click somewhere(e.g on a table row) the app to opens specific link in Safari browser not inside the UIWebView. Is that doable without writing any iOS code and instead of that make the JavaScript opens that link in Safari itself ? I have thatcode,but it doesn't help at all: HTML Code <tr class='link-to-pdf' data-href='www.example.com'> JS Code: $(".link-to-pdf").click(function () { var a = document.createElement('a'); a.setAttribute("href", this.getAttribute("data

How to show a GIF on iOS in a certain frame, not show it until fully loaded, and allow zoom?

筅森魡賤 提交于 2019-12-01 17:56:38
When a user selects a GIF, I want to present an overlay on top of everything showing the GIF. I know there's a few ways on iOS to do this. There's the great UIImage+animatedGIF which works decently well, but for longer GIFs they're very slow and don't play back at the same speed as a UIWebView would (which plays at the accurate playback speed). It sucks, because if that category didn't play them back slowly it would do everything I need. But it doesn't, so I tried with UIWebView, however I'm confused about three things: How do I get size that the UIWebView should be when presented (its frame)?

How to resolve “Frame Load Interrupted” error in UIWebView?

冷暖自知 提交于 2019-12-01 15:47:51
In an app I'm contracted to build, I'm pulling a list of YouTube videos and allowing them to be displayed in the app. However, when a user taps a cell in the YouTube view's navigation controller and the modal view with a UIWebView appears, the UIWebView returns the error "Frame load interrupted." I've run it through the debugger dozens of times, and everything seems to go well until I initialize the NSURLRequest. When the modal view is displayed, here is the code that runs in the ViewController's -viewDidLoad method: - (void)viewDidLoad { [super viewDidLoad]; _webView = [[UIWebView alloc] init

WebKitErrorDomain error 101

大兔子大兔子 提交于 2019-12-01 15:28:53
The following code produces and error of: WebKitErrorDomain error 101 code: -(Void) searchBarSearchButtonClicked: (UISearchBar *) activeSearchBar { NSString * query = [searchBar.text stringByReplacingOccurrencesOfString: @ "" withString: @ "+"]; NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ "http://http://www.google.com/search?q =%, query]]; NSURLRequest * requestObj = [NSURLRequest requestWithURL: url]; [Home loadRequest: requestObj]; } -(Void) loadView { [Super loadView]; CGRect bounds = [[UIScreen mainScreen] applicationFrame]; searchBar = [[UISearchBar alloc]

WebKitErrorDomain error 101

家住魔仙堡 提交于 2019-12-01 15:08:50
问题 The following code produces and error of: WebKitErrorDomain error 101 code: -(Void) searchBarSearchButtonClicked: (UISearchBar *) activeSearchBar { NSString * query = [searchBar.text stringByReplacingOccurrencesOfString: @ "" withString: @ "+"]; NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ "http://http://www.google.com/search?q =%, query]]; NSURLRequest * requestObj = [NSURLRequest requestWithURL: url]; [Home loadRequest: requestObj]; } -(Void) loadView { [Super loadView]

Knowing when AJAX has loaded in UIWebView

隐身守侯 提交于 2019-12-01 14:57:39
I have a UIWebView and one page has an AJAX component whose content changes when the user clicks a button. How can I know when the content has loaded inside the UIWebView ? Ishan You'll need to do two things: In your JavaScript code, have the XMLHTTPRequest signal that the AJAX request is complete with a custom URL: var req = new XMLHttpRequest(); req.open('GET', 'http://www.mozilla.org/', true); req.onreadystatechange = function (aEvt) { if (req.readyState == 4) { if(req.status == 200) { window.location = "myspecialurl:foo" } } }; In your native code, you'll need to implement a UIWebView

Downloading image into bundle?

爷,独闯天下 提交于 2019-12-01 14:57:29
I display text and images in a UIWebView. Content isn't always the same. I access images within the content using the bundle path. For an inbetween versions update of content, I'd like to allows users the ability to download new content (text & images). This new content will also display in a UIWebView. The problem is I will have to use a disk path rather than my common pattern of using the bundle path. Unless there is a way to repackage the image at runtime into the bundle. Once the next app store update for the app is availble, all of the previously downloaded images will be in the app