Check Mobile App
Read now
Start a Project

Show an Alert View in UIWebView

Save

This article is on how to show an Alert view in UIWebView.

The weblinks containing the pop-ups or alerts can be handled in WebKit.

UIWebView delegate functions can handle the alert elegantly in the iOS application.

So let’s start learning.

Integrating Alert View in Weblink

Firstly let’s create a web link that contains an alert view.

Go to our favorite website W3School

It’s time to add the code to display the alert on the website.

Add the below code for displaying the alert view on the website.

Now hit run in the editor, and you will see the webpage with a button named “Show Alert”

Now click on the Show Alert button, and you will see a pop-up on the webpage as below.

Show an Alert View in UIWebView

Copy the web link, we have to open this inside our UIWebview in Swift.

Now let’s Show an Alert View in UIWebView.

Integrating Alert View in UIWebView

We will open the copied web link on the previous section inside our UIWebView in Swift.

Create an Xcode project and add UIWebView in your ViewController class as below.

Now add the WebView function runJavaScriptAlertPanelWithMessage that will actually handle the displaying of the alert in our application.

This will pop up an alert view in our application as shown below.

Show an alert View in UIWebView

Now you are done integrating the Alert view in UIWebview.

That’s all for this article.

We hope you liked the article.

Please visit my other blogs here.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

The support is fast and do everything in their power to make it perfect. If you need customization it's also done right away. I had massive research to select Mobikul and now I'm sure it was the right one.

Igor Souza

Igor Souza

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home