UIWebview show pdf with Done or Back Button - ios

I had an application with many internal pages running on swift3 using UIWebView? On moving from one page to another it shows back button, but when I click on "Download pdf" button to view pdf, it doesn't show "Back" or "Done" button after opening the pdf inside UIWebView. Please guide me with any possible solutions.
Thank you.

you can use UIDocumentInteractionController.Please check this link, may help you https://developer.apple.com/documentation/uikit/uidocumentinteractioncontroller
UIDocumentInteractionController *documentInteractionController =[UIDocumentInteractionController interactionControllerWithURL:URLOfPDF];[documentInteractionController setDelegate:self];[documentInteractionController presentPreviewAnimated:YES];

Related

Unable to load the URL in iOS WebView when the button is clicked for the first time

The mobile app is all about showing a SharePoint website in a WebView. I am trying to get the URL of a third party website on click of a button which is a part of the WebView. Based on this URL, I am trying to show an alert. On the first click of the button, the URL I am looking for, is not loading and hence the alert is not showing up. However, I am able to see the URL for the second click of the button and I'm able to see the alert as well.
Any help would be appreciated.
Thanks in Advance.

how to open external link from webview in popup window ios

I have embedded a webview in the view that loads a website. Now, I need to open external links inside webview in popup window.
Can anybody help me.
Thank you.
If you want to open popup's inside the UIWebview html rewriting is the best option.. write your html code in a file and load it in the webview
refer to the question for details..
Opening popup links in UIWebView, possible?

ios webview open link in different tab/webview

I have two tabs (things that are at the bottom of the 'Clock' app) both have webviews. how can I make a link that was clicked on first tab's webview be opened (and show to user) in second tab second webview if there is a string "test" in the URL.
thnak you!
You'll need to set a delegate on your UIWebView and then handle the delegate method to be able to intercept the click and send it to the tab you want.
Here's an example: UIWebView open links in Safari

UIWebView -> "Add to Reading list is not displaying"

I have a UIWebView and I open a website in it. The website contains lot of hyperlinks. I get an action sheet when I long-press it in Safari: Add to Reading list, Copy and Open are displaying. However in my UIWebView Add to Reading list is not displaying (below 6.1).
You need to add that option programmatically yourself. Also note that you cannot access Safari's Reading List programmatically.
For doing this, you would need to add an UIActionSheet to your view and display it when a link is tapped in your UIWebView.
For your reference have a look at this question: how to change UIWebView Tap events
I solved above problem. I customized the contextual menu of UIWebView,
.
Sample application for customize the contextual menu of UIWebView

PDF with a back button on the iPhone/iPad in HTML5?

I'm trying to write an HTML5 application for iOS (not the routers) that opens PDFs. Right now I'm just using <a href="some.pdf" type="application/pdf">. This exits the application and opens the PDF in Safari.
How do I get the back button to take the user back to my application, or view the PDF without Safari chrome?
I'm using Sencha Touch and would deploy with PhoneGap.
I don't know of an easy way to do this as your application is hosted in a singular UIWebView as well so displaying a PDF in it would result in the inability to display a back button or for the user to navigate back to your application.
The only was that I could envision to do this would be to write a PhoneGap plugin that would create another UIWebView set it to the PDF's content, and add it to the master UIViewController. You would then set the view to be x pixels from the top which would allow you to display a back button in a toolbar fashion. When they click back, the plugin unloads the PDF, destroys the view, and your application is still going. (You could also just create a View on top with a native back button that just hides the PDF's UIWebView when clicked).
You should create an NSURLRequest pointing to the PDF and feed it to your UIWebView:
- (void)viewDidLoad {
[super viewDidLoad];
[webView loadRequest:[NSURLRequest requestWithURL:pdfUrl]];
}
I don't know where you get your PDF from, but if you need to intercept the click on the link
you can also do that by defining your UIWebView's delegate
-webView:shouldStartLoadWithRequest:navigationType:.

Resources