Swift UI special training Alertview Warning box

Source: Internet
Author: User

Sometimes we need a frame to confirm or return when we do the operation, which is alertview. In the previous project, when we clicked the Stop button, the pop-up window was confirmed. Pop-up window This action occurs when we click the Stop button, so the Alertview code is added to the Stop button action, the code is as follows:

@IBAction func Stopbutton (Sender:uibutton) {let                stopdownloadconfirm = Uialertview (title: "Warning", message: "Downloading, Are you sure you want to cancel the download? ", Delegate:self, Cancelbuttontitle:" No ", Otherbuttontitles:" yes ")        stopdownloadconfirm.show ()                    }
Of course, because the agent chooses self, the controller needs to integrate the uialertviewdelegate, which works as follows:



Careful little partner may have found that the last word hidden gear statement is no longer, now click the Stop button is triggered by this alertview, and the operation of the gear is put in a new method:

Func Alertview (Alertview:uialertview, Clickedbuttonatindex buttonindex:int) {        if Buttonindex = = 1 {        Loading.stopanimating ()        }    }

The function of Judgment statement is: When we click "Yes" will stop the rotation of the gear, click No effect. Now to test, first click on the download, there are rotating gears:



Then click the Stop button, select No, the gears are still turning, select Yes, the gears disappear.

Swift UI special training Alertview Warning box

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.