Xcode Tutorial - How to use a UIWebView (Load PDF Files, local HTML documents/ etc...)

Xcode Tutorial - How to use a UIWebView (Load PDF Files, local HTML documents/ etc...)


In this Xcode tutorial I will be showing you how to use a UIWebView in your iOS Application. You can use it to load a website from the internet, load a local file (such as a PDF file) and more.

Links:
Website: http://supertecnoboff.co.uk
Twitter: http://twitter.com/supertecnoboff
Tumblr: http://supertecnoboff.tumblr.com
Facebook: http://facebook.com/supertecnoboff
iOS Apps: http://itunes.apple.com/artist/supert...
Closed Caption:

hey guys sleep 1000 fear and then we
have another xk 20 feet today
now this tutorial I'm going to be one
scan covering one of my old Charles this
is going to be talking about you I web
these now in a previous tutorial of UI
web these I talked about how could a
uiwebview to application which loads a
website online blow seven the end of
that teacher that I would make another
video which covers how to load a webpage
or HTML document for example which is
stored offline or basically in the
resources folder of your iOS application
so here I've got a simple little group
here I've got a simple web app here it's
a basically well just hdmi made in a Jap
dash code and i'm just going to launch
here in the iOS simulator in safari so
doesn't really do much but you get the
idea is just for demonstration purposes
and sort of a little button here too man
and so on but it's all done in HTML you
can see right and what we're gonna do is
we're gonna be servin storing this
online and then loading it in the UI
webview we're gonna load this locally in
the resource from the resources folder
in our iOS application so let's close
this and start a new Xcode project gonna
call this i'm going to select a single
View application or if you're on the
older iOS four an old SD case it will be
a few base application- selects a local
weather you save this to the desktop we
go
so the very first thing I'm gonna do is
of course add in our HTML documents to
the resources or in this case the
supporting files folder of iOS
application so just drag and drop that
in him and here just one thing to note
here when you want to load documents
such as HTML document locally it's
better to select create folders
references for any added folders just
select this option when you're copying
the files now I don't know
why but when you select this option it
doesn't work when you're loading the
local HTML farm and but when you set
this when you select this option it does
work now I don't exactly know why but
all the forum's I saw always said this
and I try to know if you use quite been
in the past and this way by selecting
this option it works a lot better said
well let's just copy those items in so
here they are here RV here is the local
HTML forint and if we open that folder
we have all the contents of that folder
in xcode project that's all good now
let's come to our viewcontroller h and
begin with the coding so it's really
simple here we're just going to open and
close to curly brackets and make an
iboutlet 4i uiwebview so I be outlet
place why web the space-car i'm going to
give our web view a name I'm going to
call this with you
very simple now we're going to come and
a day a spotty function so that property
space open bracket non-atomic comma
space contain retain close brackets
space UI webview a star and now type in
the name of our web so in my case its
web deep semicolon safe now we're going
to come into the viewcontroller am far
and because we used a property function
we're gonna be synthesized it so at
synthesized and then type in the name of
our web usin my classes lucky semicolon
save that's so good
now what I'm going to do for the
purposes of this tutorial I'm going to
make it so that when our application
loads the webview starts loading the
HTML content so i'm going to use the
super viewdidload function in search
delete this year and type in the
following code NS string space star path
people space equals space open to square
brackets and it's bundle space main
London close square brackets or just
close one square
it's space pass for resource then at and
openly close to quotation marks and here
we're going to put in the name of our
HTML document now in most cases lot of
people will be implementing for example
web apps and just like a website any web
app starts with the index fun
so you're going to want to type an index
in and then off type well in this case
is HTML so i'm going to put at open to
quotation marks and in between the
quotation marks in the format of the
file so here at speech the amount after
the closing quotation mark space and
then type in the following code in the
dictionary or directory sorry that sign
open to crack open to quotation marks
and in between these quotation put
quotation marks
we're going to write write in the name
of the folder of which are HTML
documents are stored in so in this case
the name of the photo is local HTML
similar type n local then after the
closing quotation marks close the square
bracket semicolon say we come down the
line and type in NS URL space star URL
space people's space open the square
brackets NS around space file URL with
path then put close the square bracket
semicolon come down line now for next
line of code then NS URL request based
our request equal space sorry open
square brackets and s URL request space
request with you
RL and then put around poster brackets
semicolon safe and come down for our
very last line of code which is going to
be open square brackets now type in the
name of our web view so in this case is
a web meeting space load request code on
and then type in request close bracket
semicolon saved and that's it we're done
so that's it for the code so now we go
to come into our xib file and add in a
uiwebview so that's coming to the
viewcontroller the xib file open this up
and make sure our files owner is
selected or actually selected once we
add in the UI webview sorry
so it's going to open this up and I'm
going to drag and drop a simple UI
webview there we go now select all files
owner come into the connections tab in
interface builder hip and connect the
iboutlet which in this case is webview
tu ru I web-like so safe and now let's
build one and this should work perfectly
fine so as you can see no issues here
whatsoever so it's all works fine and
here is rui overview and it has loaded
our local HTML document so can press
this button and the idea is it should
work although maybe that's to do with my
code in dash code but you get the idea
it does work here has loaded our HTML
document as you can see so is there is
our uiwebview and that's is and that is
how we can load a local HTML document
now this also has some other uses for
example you can also load PDF documents
like this as well and I just quickly
show you that as well so if we stop this
here come into the control that Haitians
really very simple is not much to it but
basically you type in the name of your
PDF here so I'm going to just to have a
simple PDF this one right
I'm going to do on these pages and
quickly make a PDF file and this is just
to demonstrate how you can use a PDF
file in a UI webview as well so let's
just do that make our PDF fun
so this is a PDF file save as a PDF file
we're gonna have an explosion no save it
save it
PDF PDF PDF hope so yeah on our desktop
we have a PDF file here and it's called
PDF from enough so we're just gonna drag
and drop this into our supporting files
or if you're on the older sdk is going
to drag and drop it into the resources
folder going to select create groups for
need added folders in this case and
finish so here is a PDF file
well let's come back into the control RM
file and we're just going to change a
few things here so here what it says for
path resource we're going to change this
to the name of our PDF files in my case
it's called literally called PDF and off
type well the document is a PDF on some
of the media and in directory
well it's not technically in any
directory so you can probably like and
we should be able to build and run and
there we have it guys
so this is rui worldview and it's
loading a PDF farm now obviously if you
have more pages will scroll down and the
all the pages in this case we only have
one page of our PDF phone and this is it
that we have guys that is how you can
use a uiwebview to load local data from
the resources or in the new SDK from the
supporting farms folder and this can
load sounds like PDF HTML documents java
documents things like that so thank you
very much watching I hope this tutorial
has helped
if it has please subscribe to my youtube
channel and I'll see you in my next
video bye

Video Length: 11:00
Uploaded By: Supertecnoboff
Published: 7/1/2011
View Count: 46,877

Related Software Products
Html To PDF
Html To PDF

Published By:
Utralshareware Software

Description:
Do you want to convert your html files into PDF? Html to PDF is the batch html to pdf conversion utility you want. It takes html file or remote webpage as input, load the html content into standard browser, render the html content into a standard PDF file. It can be used on multiple OS platform like linux and Windows. Key Benefits: Convert html into PDF on the fly With Html To PDF, it can convert your Html documents into Adobe PDF files easily. It can handle the complex webpages on the ...


Related Videos
Creating Dynamic PDF in PHP from HTML
Creating Dynamic PDF in PHP from HTML

Video Length: 13:39
Uploaded By: yrrhelp (10/16/2014)
View Count: 252,724

Converting PDF Files to HTML
Converting PDF Files to HTML

Video Length: 06:28
Uploaded By: Lori Kassuba (5/21/2013)
View Count: 187,200

How To Convert HTML to PDF Document
How To Convert HTML to PDF Document

Video Length: 05:14
Uploaded By: Sathya Moorthi (4/9/2014)
View Count: 162,656

How to Convert PDF to Word, PDF to Excel, PDF to HTML, & Edit PDF files with deskUNPDF
How to Convert PDF to Word, PDF to Excel, PDF to HTML, & Edit PDF files with deskUNPDF

Video Length: 04:14
Uploaded By: Docudesk Corporation (4/26/2010)
View Count: 67,715

Create HTML Email from a PDF-Part 2
Create HTML Email from a PDF-Part 2

Video Length: 01:07
Uploaded By: Ed Hart (2/28/2011)
View Count: 61,507

How to Convert PDF to Word, Excel, PowerPoint, EPUB, HTML and Text on Mac?
How to Convert PDF to Word, Excel, PowerPoint, EPUB, HTML and Text on Mac?

Video Length: 01:58
Uploaded By: Melvinjames18 (7/7/2010)
View Count: 49,476

How To Convert HTML to PDF, HTML to Excel, HTML to Word, & PDF to HTML
How To Convert HTML to PDF, HTML to Excel, HTML to Word, & PDF to HTML

Video Length: 02:51
Uploaded By: Docudesk Corporation (4/26/2010)
View Count: 38,019

Copyright © 2026, Ivertech. All rights reserved.