uiwebview

Has anybody found a way to load HTTPS pages with an invalid server certificate using UIWebView?

为君一笑 提交于 2019-11-28 19:44:09
If a user attempts to load a https web page in Mobile Safari and the server's certificate validation check fails (its expired, revoked, self-signed etc.) then the user is presented is presented with a warning message and asked if they want to continue or not. Similarly NSURLConnection offers the ability for the implementator to decide firstly how to check the certificate and then decide how to proceed if it fails, so in this situation too it would be possible to display a warning to the user and offer them the opportunity to continue loading the page or not. However it seems when loading a

UIWebView CSS injection using JavaScript

冷暖自知 提交于 2019-11-28 19:39:04
I'm trying to inject a local css file into an UIWebView that finished loading website such as google etc. I'm trying with JavaScript but with no success. - (void)webViewDidFinishLoad:(UIWebView *)webView { NSString *cssPath = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"styles.css"]]; NSURL *baseURL = [NSURL fileURLWithPath:cssPath]; NSString *js = [NSString stringWithFormat:@"var fileref = document.createElement('link'); fileref.setAttribute('rel', 'stylesheet'); fileref.setAttribute('type', 'text/css'); fileref.setAttribute('href', %

How to disable long touch in UIWebView?

℡╲_俬逩灬. 提交于 2019-11-28 19:17:59
I want to disable long-touch from the application. I have no control on the HTML that I am loading on my WebView. In webViewDidFinishLoad delegate I run a javascript on the loaded html page that disable the long touch. [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none'; document.body.style.KhtmlUserSelect='none'"]; You could try to override the following methods from the view controller : - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *

Transition to iOS 7: correct viewport setting for jQuery/iPhone Webapps viewed on iPads

社会主义新天地 提交于 2019-11-28 19:14:46
We have an app with essentially one UIWebView which is set to "iPhone App" in XCode. Until now all worked fine, but using the iOS 7 iPad Simulator the App now appears in "Full Screen" immediately, which would not be the problem, but the WebView also appears to be zoomed in. I only see the upper right 1/4 of the website thats loaded and have to scroll to see the rest. We use jQuery mobile 1.3.1 in the application. edit I found the error. It seems the semantics of the viewport meta-element changed between iOS versions. Changing <meta name="viewport" content="width=device-width, initial-scale=1">

UIWebView Doesn't Load Completely, Height Varies

梦想的初衷 提交于 2019-11-28 19:01:30
I have a view controller containing some labels and a UIWebView that is loading some html in it. All these labels and UIWebView are subviews of a UIScrollView. I have disabled the scrolling of UIWebView so the labels and UIWebView scrolls all together inside the UIScrollView. Then i took found the size of the content inside the UiWebView, changed the UIWebView size according to the content size and then set the size of the scroll view to the size of the webview. This is how i did it by adding the following code in webViewDidFinishLoad: CGRect frame = myWebView.frame; frame.size.height = 1;

Ignoring Invalid Server Certificates with UIWebView [duplicate]

…衆ロ難τιáo~ 提交于 2019-11-28 18:41:21
This question already has an answer here: UIWebView to view self signed websites (No private api, not NSURLConnection) - is it possible? 9 answers We have an iOS app that uses a UIWebView to display content. We load it up with data with code that looks like this: NSURL *url = [NSURL URLWithString:myURLString]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [_webView setDelegate:self]; [_webView loadRequest:request]; This used to work fine with HTTP requests, but now we are using HTTPS against a server with a self-signed SSL certificate. When the above is run, the webView

How to display html formatted text in ios label

霸气de小男生 提交于 2019-11-28 18:26:40
问题 I would like to display html formatted text on a UILabel in IOS. In Android, it has api like this .setText(Html.fromHtml(somestring)); Set TextView text from html-formatted string resource in XML I would like to know what / if there is an equivalent in ios? I search and find this thread: How to show HTML text from API on the iPhone? But it suggests using UIWebView . I need to display html formatted string in each table cell, so I think have 1 webview per row seems a bit heavy. Is that any

How can I set the “User-Agent” header of a UIWebView in Swift

蹲街弑〆低调 提交于 2019-11-28 18:21:09
I am using Xcode 6 for an iOS App with Swift. I have got a simple ViewController with an embedded UIWebView. You can find the code below. Now I want to change the User-Agent HTTP header. I tried to use the setValue method of NSURLRequest but it didn't work (see uncommented line). Does anyone know how to do that? import UIKit class WebViewController: UIViewController { @IBOutlet weak var webView: UIWebView! override func viewDidAppear(animated: Bool) { var url = NSURL(string: "https://www.samplepage.com") var request = NSMutableURLRequest(URL: url) // request.setValue("Custom-Agent",

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

為{幸葍}努か 提交于 2019-11-28 18:12:59
I know when its done loading... (webViewDidFinishLoad), but I want to use [webView.layer renderInContext:UIGraphicsGetCurrentContext()]; to create an image from the UIWebView. Occasionally I get the image prior to the webView finishing its rendering. I can use performSelector to delay the get of the image, but the amount of wait is arbitrary and brittle. 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

UIWebView Keyboard - Getting rid of the “Previous/Next/Done” bar

主宰稳场 提交于 2019-11-28 17:36:14
I want to get rid of the bar on top of the keyboard that appears when you focus a text field in a webview. We have some other ways of handling this and it's redundant and unnecessary. webview keyboard bar http://beautifulpixel.com/assets/iPhone_Simulator-20100120-152330.png If you hit this problem , make sure to head over to https://bugreport.apple.com and duplicate rdar://9844216 yun - (void)viewDidLoad { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; } - (void)viewWillAppear:(BOOL)animated { [super