uiwebview

How to get selection text from UIWebView?

 ̄綄美尐妖づ 提交于 2020-01-09 13:08:13
问题 , Hello, everyone. I'm developing my app which has a feature to post article from website. This is a picture of UIWebview with UIMenuController. It was possible to get event when user tap the button. but I can't find the way to get the text the user selected. In UITextView case, it has 'selectedRange' property, so it is easy to get selection text. UIMenuItem *facebookMenuItem = [[UIMenuItem alloc] initWithTitle:@"Facebook" action:@selector(facebookMenuItemTapped:)]; UIMenuItem

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

不羁岁月 提交于 2020-01-09 12:51:12
问题 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

UIWebView stringByEvaluatingJavaScriptFromString hangs on iOS5.0/5.1 when called using GCD

元气小坏坏 提交于 2020-01-09 10:22:28
问题 I have the following code in viewDidLoad , which works properly on iOS 4.3, but it hangs on iOS 5/5.1. On iOS 5/5.1, the alert dialog is shown but can not be dismissed, the UI thread freezes, the OK button just can not be clicked. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_sync(dispatch_get_main_queue(), ^{ [self.webview stringByEvaluatingJavaScriptFromString:@"alert('HELLO WORLD!')"]; }); }); Is this a bug? 回答1: After test, I consider it as a

UIWebView stringByEvaluatingJavaScriptFromString hangs on iOS5.0/5.1 when called using GCD

半世苍凉 提交于 2020-01-09 10:22:28
问题 I have the following code in viewDidLoad , which works properly on iOS 4.3, but it hangs on iOS 5/5.1. On iOS 5/5.1, the alert dialog is shown but can not be dismissed, the UI thread freezes, the OK button just can not be clicked. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_sync(dispatch_get_main_queue(), ^{ [self.webview stringByEvaluatingJavaScriptFromString:@"alert('HELLO WORLD!')"]; }); }); Is this a bug? 回答1: After test, I consider it as a

UIWebView — load external website, programmatically set initial zoom scale, and allow user to zoom afterwards

空扰寡人 提交于 2020-01-09 04:43:22
问题 Is it possible to do all of the above? SO has given me a great way to set the initial zoom scale here. Namely, to include the following line in my webViewDidFinishLoad method: [webView stringByEvaluatingJavaScriptFromString: @"document.body.style.zoom = 5.0;"]; But what I still can't do is allow the user to change the zoom scale after the program initially sets it. If I set scalePagesToFit to NO, the user can't change the zoom scale. And if I set scalePagesToFit to YES, it overrides my

How to do authentication in UIWebView properly?

左心房为你撑大大i 提交于 2020-01-09 04:22:07
问题 I would like to support HTTP Basic Authentication in my UIWebView. At the moment, I am canceling requests in webView:shouldStartLoadWithRequest:navigationType: then handle them in my own NSURLConnectionDelegate to check for and provide credentials if needed. I then use loadData:MIMEType:textEncodingName:baseURL: to present HTML in the web view. That works fine for any URLs that are passed to the delegate. My problem is that the delegate is never called for embedded elements, like images,

UIMoviePlayerControllerDidEnterFullscreenNotification doesn't work in iOS8

橙三吉。 提交于 2020-01-09 03:21:53
问题 I am using UIWebView to play a youtube video with iFrame. I am using UIMoviePlayerControllerDidEnterFullscreenNotification to detect youtube screen into fullscreen. Like below code : [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(myMovieEnterFullScreen:) name: @"UIMoviePlayerControllerDidEnterFullscreenNotification" object: nil]; It works in iOS7. But I try to run it in iOS8. It doesn't work. I think the notification name has be changed. Has any alternative to

How to block Load image in UIWebView iOS?

早过忘川 提交于 2020-01-07 06:56:01
问题 I want to use UIWebView to load url, but don't load the image in the webpage.I want UIWebView just display the plain text in the webpage. thanks. 回答1: Your best bet is to set a delegate for the webView and implement the delegate method: webView:shouldStartLoadWithRequest:navigationType: Depending on how the page is constructed, you could get a notification for when the image wants to load, and return NO to stop the webView from loading that resource. Edit: If you didn't set your web view's

Loading links from an XML file onto a UIWebView (SIGABRT error)

爷,独闯天下 提交于 2020-01-07 06:34:08
问题 I have been trying to parse an XML file in order to get articles from a website using background fetch. Someone gave me an answer to this question here. However, his answer resulted in an SIGABRT error. Could someone please look at my code and see what my problem is? Thanks in advance. My CODE: NewsViewController.h (This file loads a uitableview that runs the background fetch to get the articles): #import <UIKit/UIKit.h> @interface NewsViewController : UIViewController<UITableViewDelegate,

Is is possible to communicate between UINavigationController and web page loaded inside UIWebView?

◇◆丶佛笑我妖孽 提交于 2020-01-07 05:35:34
问题 I am new to iOS development. I will try my best to explain my question, please pardon me if you find it silly. I was wondering if one can load a subview in a UINavigationController by clicking a link inside a UIWebView. Explaining it further, let's say there is UINavigationController that has a subview and that subview has a UIWebView called A, and there is another subview(that is not loaded yet) called B. Is is possible to load B (or perform any other native Objective C event) when user taps