uiwebview

How to detect redirect in a UIWebView

丶灬走出姿态 提交于 2019-11-29 05:31:37
I am using a UIWebView as an embedded browser within my app. The problem I have is tracking the URL that should be displayed in the URL bar. When doing a Google search, the results page often generates links like this: http://www.google.com/url?sa=t&source=web&cd=1&ved=0CC4QFjAA&url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FDog&rct=j&q=dogs&ei=27XeTc6RFIWEvAO858DHBQ&usg=AFQjCNGkEDcWzea4pSlurHhcuQfqFcp_pw When the user clicks this link, the UIWebView first reports this link and then the redirected link in shouldStartLoadWithRequest:navigationType: . How can I tell this is a redirect as opposed to

UIWebView webViewDidFinishLoad not getting called iOS

独自空忆成欢 提交于 2019-11-29 05:22:05
问题 I am loading some file from document directory using UIWebView. I have set the delegate of UIWebView and I am responding to 2 methods of delegate that is webViewDidStartLoad and webViewDidFinishLoad I am receiving the webViewDidStartLoad But I am not receiving webViewDidFinishLoad method. Below is the code: @interface MyView: UIViewController <UIWebViewDelegate> { UIWebView *webView; } @property (nonatomic, retain) UIWebView *webView; ========================= Class ==========================

Get HTTP Response header on UIWebView

南笙酒味 提交于 2019-11-29 05:19:05
How can I get HTTP headers response from WebView? I've found semi-solutions at Stackoverflow , but it's written on Objective-C and can't convert it to Swift (I've tried with my poor Obj-C knowledge). Objective-C code: - (void)webViewDidFinishLoad:(UIWebView *)webView { NSCachedURLResponse *resp = [[NSURLCache sharedURLCache] cachedResponseForRequest:webView.request]; NSLog(@"%@",[(NSHTTPURLResponse*)resp.response allHeaderFields]); } How that code will look at Swift? Maybe now we have better ways to do so? Caching is not always enabled. Swift Swift is more stringent ; you want to protect

Youtube - iPhone - displaying UIWebView of video

僤鯓⒐⒋嵵緔 提交于 2019-11-29 05:18:26
I have a script in my app that loads a Youtube link in a section of the UIView, the link is provided by my server (mySQL/using php) and from that it is loaded... this script below works fine..... however... Here is what I have right now, I was looking to remove the programmatically part (where it gives the dimensions and possibly replace it with a UIWebView) to it, so I could improvise using IB, this will help when my application launches, a quick animation occurs and then I want this youtube link to load and display after viewDidLoad is completed. .h file: - (void)embedYouTube:(NSString *

Injecting CSS into UIWebView using JavaScript

时光毁灭记忆、已成空白 提交于 2019-11-29 05:18:14
问题 I am attempting to inject a local CSS file to override the styling of a webpage. The webpage is presented in a UIWebView container in iOS. However I am not able to get my code to work. See the snippet of my delegate method below. This code runs (I can see the NSLog message) but I do not see the results of it's execution on the page. I know it can't be the CSS I wrote because in this case I took the pages own CSS file and simply changed some colors. (In order to test this method) -(void

How to preselect contenteditable field in UIWebView iOS5

烈酒焚心 提交于 2019-11-29 04:50:16
First of all I know contenteditable is only iOS 5 I have accounted for this - we are giving users with iOS 5 a feature to allow Rich Text pasting using contenteditable. This feature works great so far all I want to do is when the view appears to set the contenteditable field as active (pre-select it) so that the keyboard appears and the user can begin typing right-away. Here is the local html file I am using for the UIWebView <html> <body> <div id="content" contenteditable="true" style="font-family: Helvetica">PLACEHOLDER</div> </body> </html> I have already tried using some javascript to

How to embed local images in UIWebView?

我的未来我决定 提交于 2019-11-29 04:48:08
Is there an easy way to embed local images in an UIWebView? For example, I would want to embed an logo.png image in the UIWebView, which I've added to the Resources folder in Xcode. Would I simply add an img HTML tag for this? yes it's very simple but, for others, remember to put "file://" at the beginning of your path for example: NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"png"]; [myWebView loadHTMLString:[NSString stringWithFormat:@"<html><body><img src=\"file://%@\"></body></html>",path] baseURL:nil]; 来源: https://stackoverflow.com/questions/3808451/how-to-embed

Delete cookies UIWebView

孤街浪徒 提交于 2019-11-29 04:47:44
How to delete cookies in UIWebView? This code: NSArray* cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]; for (NSHTTPCookie *cookie in cookies) { [cookies deleteCookie:cookie]; } deletes cookies but when I restart my application, there are same cookies in NSHTTPCookieStorage. Sometimes this code works, but i want to make it work everytime.How to solve this problem? Try something like this: NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage]; NSArray* facebookCookies = [cookies cookiesForURL: [NSURL URLWithString:@"http://login.facebook.com"]]; for

XSLT in a UIWebView using iOS SDK 4.2

北慕城南 提交于 2019-11-29 04:42:37
Is it possible to use XSLT in a UIWebView using iOS SDK 4.2? Alternatively, is it possible to use XSLT in iOS SDK 4.2 outside of a UIWebView? I have seen similar questions to this, but they seem to be dated and refer to pre-4.0 iOS SDKs. If it is possible, a link to a simple iOS XSLT example would be great too. TIA. The answer is yes. Here's an example: NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWithPath:path]; NSString *xml = @"<?xml version=\"1.0\"?><?xml-stylesheet type=\"text/xsl\" href=\"greeting.xsl\"?><greeting>Hello, World!</greeting>"; [self

Opening a new UIViewController when a link on a UIWebView is clicked

偶尔善良 提交于 2019-11-29 04:14:54
问题 I found this thread which matches my problem: Clicking a link in UIWebView pushes onto the NavigationView stack However, the following situations are different: Instead of using a navigationController, I am using a View Based application to manually switch to different viewcontroller when corresponding buttons are pressed. Rather than using links I am using onClick method to detect when a user clicks on something on a UIWebView and trying to open a new ViewController with a new UIWebView.