how to intercept Button click inside UIWebview on IOS?

You can do the following: In your HTML <a class=”yourButton” href=”https://stackoverflow.com/questions/10992339/inapp://capture”>Button Text</a> In your UIWebViewDelegate – (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if ([request.URL.scheme isEqualToString:@”inapp”]) { if ([request.URL.host isEqualToString:@”capture”]) { // do capture action } return NO; } return YES; } I added “capture” to your button’s URL so that you could distinguish between several … Read more

Is it possible for a UIWebView to save and autofill previously entered form values (e.g., username & password)?

From my looking I don’t think there is an easy way to do it. Here is an idea of what might work though: create your uiwebview create a nsurlrequest after your webview delegate page loaded function fires look in the request’s http body find the form for login (regex for common login forms?) retrieve give … Read more

Does UIWebView send the same User-Agent in the Request Headers as mobile Safari?

Web requests made from UIWebView will not include the word “Safari” in the User Agent string. Web requests made from Mobile Safari will. This is the best way I have found for determining of a request is coming from within an app or from Mobile Safari. Sample User Agent from UIWebView within App: User-Agent: Mozilla/5.0 … Read more

how to increase font size in UIWebView

I have 2 buttons – A- and A+ @interface NSUInteger textFontSize; – (IBAction)changeTextFontSize:(id)sender { switch ([sender tag]) { case 1: // A- textFontSize = (textFontSize > 50) ? textFontSize -5 : textFontSize; break; case 2: // A+ textFontSize = (textFontSize < 160) ? textFontSize +5 : textFontSize; break; } NSString *jsString = [[NSString alloc] initWithFormat:@”document.getElementsByTagName(‘body’)[0].style.webkitTextSizeAdjust=”%d%%””, … Read more

Can I handle alert inside UIWebViewDelegate?

A better solution to this problem is to create a Category for UIWebView for the method webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame: So that you can handle the alert event in any way that you’d like. I did this because I don’t like the default behavior of UIWebView when it puts the filename of the source in the UIAlertView title. … Read more

How to embed a Youtube video into my app?

Xcode 8.2 • Swift 3.0.2 import UIKit class ViewController: UIViewController { @IBOutlet weak var wv: UIWebView! override func viewDidLoad() { super.viewDidLoad() loadYoutube(videoID: “oCm_lnoVf08”) } func loadYoutube(videoID:String) { guard let youtubeURL = URL(string: “https://www.youtube.com/embed/\(videoID)”) else { return } wv.loadRequest( URLRequest(url: youtubeURL) ) } } Xcode 7.3.1 • Swift 2.x import UIKit class ViewController: UIViewController { // … Read more

Using custom font in a UIWebView

After some Try and Error I have found a reliable way to load custom Fonts with a local CSS. 1. Add your Font to the App…make sure that the file is targeted properly to the Application 2. Then add your Font to yourApp-Info.plist 3. Run NSLog(@”Available fonts: %@”, [UIFont familyNames]); To check which name the … Read more

tech