uiwebview

UIWebView respond to Javascript calls

笑着哭i 提交于 2019-11-30 14:23:26
问题 How can I intercept Javascript calls such as window.open as Mobile Safari does? I haven't seen anything listed about this, but it must be possible somehow? Has anyone done this before? 回答1: When the page is finished loaded (webViewDidFinishLoad:), inject a window.open override. Of course it will not work for window.open which are called during page load. Then use a custom scheme to callback your objective C code. [EDIT] OK I have tested it. Now it works. Create a new "view based" project and

Reusing UIWebView is causing crashes

為{幸葍}努か 提交于 2019-11-30 14:09:49
I've read that reusing UIWebViews is kind of a bad practice. Some code I inherited at work is pushing a variety of content to a UIWebView. Powerpoints, Word documents, and video. This all works just fine under normal circumstances. When we get to switching out the content in the UIWebView too fast, it dumps. My webView is set as a property. It is hooked up in IB just fine. Normal selection from our tableView loads local content just fine. It takes rapid fire selection of either the same cell or combinations of multiple to get it to crash. I can capture some error messages for it for the

Get UIWebView response header

白昼怎懂夜的黑 提交于 2019-11-30 14:01:51
I have looked into ways to get response header from UIWebview response. This SO question discusses it. But I am unsure if this is allowed by apple. I will have a webview showing a loaded login page and need to get the response headers after a successful login. Also this does something to get status code. But it create a duplicate NSUrlConnection request. Is there any way by which I can achieve this? I would appreciate any information on this. MagicFlow In addition to the answer provided by DBD, you will need to ensure that The containing UIViewController is marked as a UIWebViewDelegate in the

Playing videos in UIWebView broken in iOS4?

随声附和 提交于 2019-11-30 13:49:53
I have an app that's worked since version 2.0 of the SDK where I create and add a UIWebView and then load the URL of an .mov to play a movie. Ever since the early version of the 4.0 beta up until the 4.0 GM this has stopped working. When I load a movie now I get the following error: :Plug-in handled load" and the movie never displays. Is this a known issue? Am I doing something wrong in 4.0? I figured this out. It appears to be an issue with iOS4 not being backward compatible with a UIWebView created with 'init' rather than 'initWithFrame'. In 2.0 - 3.1.3, you could only show video in a

Removing shadows from UIWebView

♀尐吖头ヾ 提交于 2019-11-30 13:48:33
I use a web view to display small pdf files. In the interest of aesthetics, I'd like to remove the grey border around the PDF. Is there any way around it? I've looked at various resources none of which seem to work or the solution no longer works in iOS5. Also, is there any way of stopping the scroll if there's only one page? Thanks. The shadows are actually UIImageView subviews of the UIScrollView (or the equivalent in iOS5 UIWebView). So in iOS4: for (UIView* subView in [webView subviews]) { if ([subView isKindOfClass:[UIScrollView class]]) { for (UIView* shadowView in [subView subviews]) {

Detect window.open() from UIWebView

夙愿已清 提交于 2019-11-30 13:47:00
Short question: Is it possible to detect window.open() in a UIWebView using the UIWebViewDelegate or is there another way to reach this? I need the the url when a window.open() -Event is fired to show a UIAlertView . You need to overwrite window.open() using JavaScript: [webView stringByEvaluatingJavaScriptFromString:@"window.open = function (open) { return function (url, name, features) { window.location.href = url; return window; }; } (window.open);"]; Try using this delegate methods. Hope this helps. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request

The joys of didFailLoadWithError UIWebview

对着背影说爱祢 提交于 2019-11-30 13:41:27
If you look at the code here: https://github.com/evernote/evernote-sdk-ios/blob/master/evernote-sdk-ios/internal/ENOAuthViewController.m that implement OAuth 2.0 flow in UIWebView. The author uses this code for the didFailLoadWithError delegate function: - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { if ([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102) { return; } if (error.code == NSURLErrorCancelled) { // ignore rapid repeated clicking (error code -999) return; } } Why is he ignoring those two errors (NSURLErrorCancelled) and error code

The joys of didFailLoadWithError UIWebview

限于喜欢 提交于 2019-11-30 13:21:34
问题 If you look at the code here: https://github.com/evernote/evernote-sdk-ios/blob/master/evernote-sdk-ios/internal/ENOAuthViewController.m that implement OAuth 2.0 flow in UIWebView. The author uses this code for the didFailLoadWithError delegate function: - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { if ([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102) { return; } if (error.code == NSURLErrorCancelled) { // ignore rapid repeated clicking

Cookies in UIWebView

China☆狼群 提交于 2019-11-30 13:05:48
I have a UIWebView, and I don't want it to store an cookies, so just before the webview is loaded I do: NSArray* cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]; for (NSHTTPCookie *cookie in cookies) { [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie]; } Checking the count of cookies is 0 so they are all deleted. But when I go to stackoverflow it still recognizes my Google Account and logs me in. How does this happen? I though it worked with cookies? samsam I had to deal with the exact same issue and I found 2 ways to deal with that problem. I first noticed

Stop video in UIWebView

北城以北 提交于 2019-11-30 12:47:31
问题 In my iPad App I have a modal view ( UIViewController with modal presentation style UIModalPresentationPageSheet ) Inside the view is a UIWebView with a HTML page and an embedded YouTube-Video. If I start the video and close the view, the video doesn't stop. The audio continues and you can see a small "play icon" next to the "battery icon" in the status bar. How can I stop the video? 回答1: Do integrate following code to sort out the problem. -(void)viewWillDisappear:(BOOL)animated { [webView