uiwebview

Feature detect opening in a new window/tab(target=_blank) with JavaScript

情到浓时终转凉″ 提交于 2020-01-01 04:09:29
问题 According to my research: "WebView" can disable "opening links in new windows/tabs". WebView is used by native app developers to display webpages within their app(see Twitter's app). Detecting WebView via user agent doesn't work consistently and isn't a best practice anyway. Simply attempting to open a new window with JS triggers popup blockers; making it an unreliable way to test if a new window can be opened. I need to detect when this feature is not available. Impossible? Additional

Take snapshot / screenshot of UIWebView

喜夏-厌秋 提交于 2020-01-01 03:42:05
问题 How do I take a snapshot / screenshot of the UIWebView control? 回答1: Use This: UIGraphicsBeginImageContext(rect.size); [webView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 回答2: The accepted answer is correct, however the screenshot is not in retina resolution. Using UIGraphicsBeginImageContextWithOptions and set its scale parameter 0.0f makes it capture in native resolution. UIWindow

Localizing HTML files in XCode

我是研究僧i 提交于 2020-01-01 03:41:09
问题 I have a localized iOS application in which I wish to include some localized HTML files. I can't work out how to do it. Currently, my folder structure looks like this: /myapp /en.lrproj /Localizable.strings /fr.lrproj /Localizable.strings /webviews /view1 /index.html /pic1.png /view2 /index.html /pic2.png As you can see, I currently have the views organized into their own folders with the associated images. In XCode, when I selected the Localizable.strings files I can add new localizations.

iOS preserve state of UIWebView?

大城市里の小女人 提交于 2020-01-01 03:24:15
问题 Is it possible to preserve the state of the UIWebView (e.g the current webpage, back/front list) in the current app launch ? For example, if I dealloc a webview, and at some point in the future, I want to recreate it - is it possible to give it the prior state? 回答1: Good Approach In iOS 6 and later, if you assign a value to this view’s restorationIdentifier property, it attempts to preserve its URL history, the scaling and scrolling positions for each page, and information about which page is

IOS UIWebView: How to add listeners to DOM events?

假装没事ソ 提交于 2019-12-31 23:11:39
问题 How can I add listeners to DOM events in UIWebView? For example for the following html: <button type="button" id="button1">Try it</button> Is it possible to register a listener for a button click event in IOS application that loads html in UIWebView? 回答1: Yes, you can do this with crafted url and UIWebViewDelegate methods. First, to add event listener on button tag, you should execute javascript like below (after the page is loaded) // In the UIWebViewDelegate - (void)webViewDidFinishLoad:

New error in iOS 5: WebKit discarded an uncaught exception

…衆ロ難τιáo~ 提交于 2019-12-31 22:40:11
问题 I am trying to load a UIWebView with the Facebook OAuth authorization URL and I am using the following code. When my UIWebView loads with Facebook login page, I enter my credentials, then press the "Log in" button. When I hit the button I am getting the following error: WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener:delegate: Application tried to present modally an active controller . This same code works fine with iOS 4.3

UIWebViewDelegate: webViewDidFinishLoad not called during in-page navigation

梦想的初衷 提交于 2019-12-31 21:34:55
问题 I have an app where users can navigate a pile of locally stored HTML files. I have a UIWebView , configured up correctly with a UIWebViewDelegate . Usually, when the user follows a link, shouldStartLoadWithRequest is called, followed by webViewDidFinishLoad a bit later. But, if the link is pointing to an anchor on the same page as the one which is currently displayed, only shouldStartLoadWithRequest is called. webViewDidFinishLoad does not fire. In a sense, I see that this might be expected

Notified when media player opens from UIWebView?

痴心易碎 提交于 2019-12-31 10:53:41
问题 I have got a UIViewController in my app with a UIWebView in it. The UIWebView is fixed-size and configured to open any links in a new UIViewController (browser). This works, but when I try clicking a video like YouTube or Vimeo from within the web view, it opens on top of the view controller. This would normally not be a problem, but I have an overlapping view that needs to get a message to move out of the way when this happens. Is there a notification or any other way my view controller can

Prevent iOS Webkit Long Press on Link

牧云@^-^@ 提交于 2019-12-31 10:19:19
问题 In an iOS app I'm developing, I show an UIWebView to allow the user to upgrade their account. The page contains links to show the user other informations, but you hold your finger on the link, a menu like this will pop up: As you can see, it reveals the URL of the page and the action that will be performed, which I do not want the user to see, since I don't want them to be able to copy anything as I disabled the "Copy/Cut/Paste" menu already. How would I go about disabling this menu as well?

'openURL' was deprecated in iOS 10.0: Please use openURL:options:completionHandler: instead in Swift 3 [duplicate]

烂漫一生 提交于 2019-12-31 09:11:47
问题 This question already has answers here : how to open an URL in Swift3 (6 answers) Closed 2 years ago . I have working open webLink url codes in Swift3 but when I use it gives me this warning; 'openURL' was deprecated in iOS 10.0: Please use openURL:options:completionHandler: instead How can I resolve it, my codes under below. let myUrl = "http://www.google.com" if !myUrl.isEmpty { UIApplication.shared.openURL(URL(string: "\(myUrl)")!) } Thank you. 回答1: Use like //inside scope use this let