Swift UI special training 24 building functions and detecting Web page loading events

Source: Internet
Author: User

Build a method to load a Web page request:

Func Loadurl (url:string, Web:uiwebview) {let    aurl = Nsurl (string:url) let        urlrq = Nsurlrequest (url:aurl!)        Web.loadrequest (URLRQ)        }

Then since the controller inherits the proxy, then it is necessary to implement some proxy methods, do not forget to associate the pinion indicator with the controller, and use it to indicate the page read event.

  @IBOutlet weak var loading:uiactivityindicatorview!

Apply it to the proxy method of the WebView:

   Page starts loading    func webviewdidstartload (webview:uiwebview) {        loading.startanimating ()    }    //page End loading    Func webviewdidfinishload (webview:uiwebview) {        loading.stopanimating ()    }

In addition, we know that usually if you want to load the content of the operator there is a gear next to the rotation, this is the common components of the system, the use of the following:

   Page starts loading    func webviewdidstartload (webview:uiwebview) {        loading.startanimating ()        Uiapplication.sharedapplication (). Networkactivityindicatorvisible = True    }    //page end loading    func Webviewdidfinishload (Webview:uiwebview) {        loading.stopanimating ()        uiapplication.sharedapplication (). Networkactivityindicatorvisible = False    }

By the way, learn about the use of system components.

Swift UI special training 24 building functions and detecting Web page loading events

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.