iOS Tutorial: Getting started with UIWebView

preview_player
Показать описание
In this tutorial, we take a first look at UIWebView and learn how to load an external website/URL into a web view and also how to load a file from your app bundle into a web view. UIWebView's are one of the most versatile classes in iOS and can be used to load html files, pdfs etc.
Рекомендации по теме
Комментарии
Автор

To fix the above, you would want to go into the xib file and then click on the File Inspector, then under the section Interface Builder document, you simply uncheck the Use Autolayout option.

VishalKurup
Автор

Jeremy - Items like these are best handled on the web server end. If you have to do heavy parsing/screen scraping on the iOS end, it will likely slow down your app. So what I would do is write some code on the webserver that would for example grab whatever specific data you are looking for and then only have iOS do the job of consuming it. You could use jQuery on the web server end to accomplish this.

VishalKurup
Автор

With the new Xcode (v4.5.1) and iOS6, you don't have you define @synthesize for properties. You can access the property (eg: uiWebView) defined in the interface with an underscore preceding the property (eg: _uiWebView).

sravanpatti
Автор

Hi Sabay - Let me make sure i understand this correctly - Are you asking if you can use custom fonts in conjunction with a UIWebView - If so, the short answer is Yes. I have for example used a UIWebView to load up an HTML file that is in my app bundle and then set the text in that HTML file to use a custom font (also from my app bundle). Now, If you are asking if you can use a custom font in conjunction with a web page that is NOT in your bundle, then that I am not sure of :) Hope that helps!

VishalKurup
Автор

Hi Rattanak - What you are describing is how to load a view controller modally. I have a video that shows how to do that. Just look at the list of all my videos and you should see it. Here's how you would build it - Create a button in View Controller 1 and tie it to an IBAction. In this IBAction, you would load the second view controller modally. Then in the second view controller, you add the web view AND a button to dismiss that view controller. Its actually very easy to do!

VishalKurup
Автор

John - There may be times when you want to have a view to load a webpage in your app. The purpose of this tutorial is to show you how to just that.

I am not quite sure i follow your concerns regarding spyware or monitoring.

VishalKurup
Автор

Never mind; fifth time was a charm! I rewrote & rewrote the code instead of copy pasting it (& possibly copying previous mistakes). The gif file with 101 images was 2.2 MB & I also had lots of stuff open on my MAC contributing to the problem (delay). It is working both ways now on the web as well as file in the app.
Did anybody tell you you sound like Salman Khan? Not the Bollywood kind but KhanAcademy one! Thanks again.

trivedidilip
Автор

webview working fine on simulator but not on a real device

shaikhsalim
Автор

Add tutorial to show information according date

Aviorrok
Автор

hi! could you make a tutorial on uiwebview and master detail template?

redgcted
Автор

Thanks you very much... you are the man..

Rattanak
Автор

Hi Vishal - first of all love your work. I learnt a lot from it. I would like to ask is it possible to create a tab button so when you tap it and it will bring you back to the default URL ? (the original website - like in I.E when you click on home button it will bring you back to homepage) cause at the moment with UIWebView once you navigated to some other links you can not get back to the homepage even you tap on the button that has the homepage link.

kentl
Автор

could you please if possible of a two view, which first view their two or three buttons and command a second view to load different local html files in the app.

Rattanak
Автор

Hi Joyce - I have quite a few master detail template based tutorials. Look at the rest of the videos on my channel (It may be labelled as UINavigationController)

VishalKurup
Автор

Thanks for the tutorial video Vishal, I tried it with a GIF file on my computer (local not on the web) but it did not work! The build succeeds & there are no issues or warnings showing but the GIF does not work. Wonder wether it is because the GIF file has too many frames (101) or because I also have a button on the app with an mp3 recording attached?

trivedidilip
Автор

Hi @Vishal Kurup, that's great tutorial!! Is it possible to embed custom fonts for UIWebView for web browser? e.g. I want to build UIWebView as web browser which show other custom fonts. Thanks

KhmeriPhone
Автор

webview not showing contents on areal device

shaikhsalim
Автор

Thanks for the reply. My question is second one. I want to use a custom font in conjunction with a web page (external). For example, I have a web site which is in my language/font and the font is not in the iOS. I want to create UIWebView web browser embed with my custom font. So users can see on iPhone/iPad my website in my language. I search for quite some times looking for the sample how to do this but I could not find one. Thanks

KhmeriPhone
Автор

That's odd. You are sure you had an active internet/cell connection on the device when you ran this?

VishalKurup
Автор

Did you happen to use AutoLayout when you first created your app? If so, then yes this app will crash when you run in a simulator that is lower than iOS6 - This is because auto layout is not supported in older versions of iOS - So in my case, if I run my app in the iOS 5.1 simulator, I get this error: Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'

VishalKurup
join shbcf.ru