UIWebView and UIWebViewDelegate example with Swift

preview_player
Показать описание
In this video tutorial I am showing how to create a new UIWebView and how to load information into it in three different ways:

1. Load a web page from a remote URL
2. Load short HTML string
3. Load html file stored which is a part of your mobile app.

Also I am showing you how to add UIActivity indicator to let user know that web page started loading and stop activity indicator animating when web page has finished loading.

Another nice to have example in this video is a Refresh button. I am showing you how to add a refresh button which when tapped will refresh the web page and load its content again. This is sometimes needed because internet connection is not always fast and sometimes web pages load partially only and it is good to be able to reload the page.

You can find source code to this video in my blog post at this url:

Рекомендации по теме
Комментарии
Автор

This is working well for loading local files in simple paths, but I'm having trouble if the file name has a space, or if the file or a directory in the path has non-Latin characters. Is there something else we'd need to do to manage that kind of path? Thanks!

russiangrammar
Автор

I have a problem at the last code. It said "Thread 1: EXC_BAD_INSTURCTION9code=EXC_1386_INVOP, subcode=0*0)". My app try to launch but it stops and above code appear. Any suggestion? thanks

SalaiMangPi_official
Автор

This is a great teaching video. I am new to all things apple and learning fast but having difficulty with xcode not accepting these code examples. Is there an updated version with the latest software? Problems like 'explicit conversion' reports 'as' .

EdwinDevey
Автор

Thank you Sergey for that. Really well explained for noobs like me :) I have done a menu in the left and I'ld like to show the title of the page loaded. Is there any way to write a title loaded into a variable when I press the button from the menu for example? Hope my question is clear! Cheers!

Автор

thanks..im thinking of all sorts of interesting things i can do with this..is their a script for offline mode? you didn't mention that.

JayZcontent
Автор

Great video for a beginner like me, thank you very much.

I have a question - lets say I have four  viewcontroller, VCfirst has the UIWebview which loads a string  with  with 3 links and text
<p> <a href='heading1'> H1</a> heading 1 detail </p>
<p> <a href='heading2'> H2</a> heading 1 detail </p>
<p> <a href='heading3'> H3</a> heading 1 detail </p>

I am able to open respective internal or external html sites with these link, but how do open a respective viewcontroller when I tap these links using swift

I feel I will have to  figure out which link is being tapped and then based on that use some a conditional statement but I am unable to come up with the code. I am hoping you be able to help. Thanks.

alohamd
Автор

Thanks. If you load an HTML file locally like in the third tip, is there anyway to get the javascript to work. The html file uses javascript which is stored in a resources folder but when I drag that into the project and run the html file, it can't perform any of the javascript functions. Can you help? Thanks

dylanwinn-brown
Автор

Thanks, Awesome video, I have a query, if my website has links to external webpages( for example links to share on facebook) then can i also have a return button at the bottom of the app which can return me back to the main website (webpage)?? . I will be highly grateful for your assistance . Thank you.

Razzyb
Автор

thanks !
but how to refresh page with Swipe the screen, please help me...

abumusa.alfadaniy
Автор

great movie thanks for help. My app load url. www.mywebsite.com but external url not working. example not show images external url. how can i fix this ? thanx

ayzbilisimyazlm
Автор

Hi has anyone done with accepting certificate with UIWebView in swift

ramonlee
Автор

hi NSBundle don't work help me pleas

Daniel-qouv
welcome to shbcf.ru