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