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

Why does scrolling a UIWebView *feel* so much different than scrolling any other UIScrollView?

I have the same perception. It must have to do with the webView’s scrollView deceleration rate. Just ran this test, and 1) it confirms our suspicion and 2) suggests a fix. I added a scrollView and a webView to my UI then logged the following: NSLog(@”my scroll view’s decel rate is %f”, self.scrollView.decelerationRate); NSLog(@”my web … Read more

Javascript in UIWebView callback to C/Objective-C

Update – don’t use UIWebView anymore. Use WKWebView, or better yet (if it fits your needs and you’re building for iOS 9), a Safari View Controller. But if you must use UIWebView, in your UIWebView delegate, provide an implementation for webView:shouldStartLoadWithRequest:navigationType: In your HTML or Javascript files, add functions that send URLs to a custom … Read more

How do I tell when a UIWebView is done rendering (not loading)?

This may depend upon the kind of graphics context you need the view rendered into, but you can call – (void)drawRect:(CGRect)area forViewPrintFormatter:(UIViewPrintFormatter *)formatter which apparently tricks the UIWebView into thinking that it’s being printed. This may help if your ultimate goal is to capture the complete page. We’ve had the problem recently in which even … Read more

iOS 8 SDK: modal UIWebView and camera/image picker

I found that in iOS 8.0.2 iPad does not seem to have that bug but iPhone still does. However, overriding following in the view controller containing the uiwebview -(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion And checking that there is a presentedViewController seems to work. But need to check side effects #import “UiWebViewVC.h” @interface UiWebViewVC () @property (weak, nonatomic) … Read more

Calling Javascript using UIWebView

Simple: You try to execute the JS function from Objective-C before the page even has been loaded. Implement the UIWebView’s delegate method webViewDidFinishLoad: in your UIViewController and in there you call [graphView stringByEvaluatingJavaScriptFromString:@”methodName()”]; to make sure the function gets called after the page has been loaded.

Remove gradient background from UIWebView?

Aha, yes terminology fail. I wouldn’t call that a shadow at all, but c’est la vie. Here is my type-safe code to achieve the effect. To summarise: this will hide any image-view children of the scroll view. It’s not as vulnerable to change as the (objectAtIndex:0) methods, so if Apple re-order the children of the … Read more

Handling touches inside UIWebview

No subclassing needed, just add a UITapGestureRecognizer : UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapMethod)]; [tap setNumberOfTapsRequired:1]; // Set your own number here [tap setDelegate:self]; // Add the <UIGestureRecognizerDelegate> protocol [self.myWebView addGestureRecognizer:tap]; Add the <UIGestureRecognizerDelegate> protocol in the header file, and add this method: – (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; }

UIWebView iOS5 changing user-agent

Change the “UserAgent” default value by running this code once when your app starts: NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@”Your user agent”, @”UserAgent”, nil]; [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary]; EDIT: I have used this with great success, but want to add additional details. To get a user agent, you can enable the “Developer” menu, set the user agent, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)