Read and use a .txt file with my UIwebView - swift

My app already uses a webview to display a website. I have all that working fine. One problem I do have is that the URL I want to use is actually hard coded into my project. I want the project to read all of the listed URL's in the .txt file and for each of them open them in the Safari View Controller(SVC). Like I said before, I have the app working, even the SVC, just with hard coded URL's in there. I would like it to be able to just know if the URL I clicked on is in the .txt file to open it in SVC not the webview. I saw some examples on how to read files, but nothing that incorporated a webview or SVC.

Related

swift open urls from pdf file

I'm working with pdf files that have urls inside it, and it's presented like images, I want the pdf to be presented like html file, so when the user clicks on a url inside the document it opens the url using safari
I'm using this library to read pdf files
https://github.com/Alua-Kinzhebayeva/iOS-PDF-Reader
and I have no problem to migrate to another library if it supports what I need
From a quick look at that library, it appears it is rendering each page as an image and then displaying it. It would probably be pretty tough to use that library to allow clickable links.
I don't have any experience with 3rd party solutions but theres a couple ways to do it provided by Apple.
You could show the pdf in a WKWebView or a QLPreviewController. Both have delegate methods that are called when a link is clicked.

Access downloaded pdf file path in HTML5 file system and display it in webview

In my chrome app, I am using HTML5 file system to save the pdf files to sand box.Downloading is working fine.But how do i access that downloaded file path? I want to give that path as webview source.
The best way, if it works, would be to use a filesystem URL. To get this use FileEntry.toURL
These don't work on external files (i.e. files that come from chrome.fileSystem.chooseEntry and are outside the app's sandbox) but should work for files in the app's sandbox.
Note, I am referring to filesystem:// urls not file://urls, which won't work as Marc Rochkind has pointed out in his answer.
Disclaimer: I haven't tested this, but I believe it should work.
You need to get the contents of the PDF into a data URL. See my answer to this question:
Download external pdf files to chrome packaged app's file system

Unable to see any local or remote images in UIWebView when loadHTMLString is used to load page

No matter what I try, the only way I can see any images in my UIWebView, is if I load a page using loadRequest. loadHTMLString will load everything except for images.
I have tried using all the online examples of setting the base url. Nothing seems to work. I've tried setting the base url to my bundle path, no local images display. I've tried setting the base url to http://www.google.com and pasting the google home page source into a test file, load it with loadHTMLString. The page shows up with no images.
What am I doing wrong?
I'd recommend taking a peek at this...
UIWebView links
Also you may notice that between the simulator and the real device files become case sensitive on the device... I'm not sure if UIWebView makes it case insensitive but thought it might be worth mentioning incase it gives any more food for thought.
If this doesn't work perhaps you can post your code snippet as this may help.

how to open a file in iWork in the iPad

From what I understand, UIApplication -openFile can open files externally, the application depending on the URL scheme. Say I have a pages (or word maybe?) document, and I want to open it in pages from my app. Does anyone know the URL scheme for me to do that? Is there a list anywhere? (Keynote, and Numbers would also be useful).
It doesn't work that way because you cannot transmit the file via a URL and Pages cannot access a file that is stored in your app's sandbox.
If you want to give the user the option to open a file in Pages in your UI, UIDocumentInteractionController is the way to do that. It presents a UI where the user can preview the file and select to open it in any application that supports the file type.
AFAIK it is not possible with the SDK to do this completely programmatically, i.e. without user interaction.

How can I simply add a downloadable PDF file to my page?

I want to add a pdf and word format of my resume to my portfolio page and make it downloadable. Does anyone have some simple script?
Add a link to the file and let the browser handle the download.
You may be over-complicating the problem. It's possible to use a href pointing to the location of the .pdf or .doc file, when a user clicks on this in their browser, generally they will be asked if they would like to save or open the file, depending on their OS/configuration.
If this is still confusing, leave a comment and I'll explain anything you don't get.
Create the PDF. Upload it. Add a link.
Save yourself 30 minutes tossing around with PDFGEN code.
You will want to issue or employ the Content-Disposition HTTP header to force the download otherwise some browsers may recognize the common file extensions and try to automatically open the file contents. It will feel more professional if the link actually downloads the file instead of launching an app - important for a resume I think.
Content-Disposition must be generated within the page from the server side as far as I know.
Option:
Upload your resume to Google Docs.
Add a link to the file on your portfolio page just as I do in the menu of my blog:
Use Google Docs Viewer passing to it the URL of the PDF as you can see in this link.