Jing He Weng
Jing He Weng

Reputation: 45

How to update current alertview title in swift?

I Use "UIAlertController" & "presentViewController" to show the alertview, like below

        let deviceName = bleManager.activePeripheral?.name
        let alert = UIAlertController(title: "Connecting...", message: deviceName, preferredStyle: UIAlertControllerStyle.Alert)
        presentViewController(alert, animated: true, completion: nil)

Now I want to update the current title from "Connecting" to "Searching", but the alertview can't dismiss.

How to do that?

Upvotes: 0

Views: 330

Answers (1)

EmilioPelaez
EmilioPelaez

Reputation: 19892

You can store the alert object in a property, and access it and update it whenever you need.

This includes changing the title or adding actions.

Upvotes: 2

Related Questions