UIWebView
1 //return button Events2 @IBAction func backbuttonclick ()3 {4Self.navigationcontroller?. Popviewcontrolleranimated (true)5 }6 7 8 Overridefunc viewdidload () {9 super.viewdidload ()Ten OneTitlelabel.text =titlestring A - - //Do any additional setup after loading the view. the - - //Create UIWebView -var Awebview:uiwebview = UIWebView (Frame:cgrectmake (0, $, Uiscreen.mainscreen (). Bounds.size.width, Uiscreen.mainscreen (). bounds.size.height- $)) + - + //Add to view A Self.view.addSubview (Awebview) at - //URL string -var webstring ="http://www.iphonetrain.com" - - //initializing a Nsurl object with a string type -var url:nsurl! = Nsurl (string: webstring) in - //Initialize nsurlrequest with Nsurl object tovar request:nsurlrequest =nsurlrequest (Url:url) + - //webview loading Web pages the awebview.loadrequest (Request) * $ Panax Notoginseng //Set page compression, full-screen display -Awebview.scalespagetofit =true the + Avar htmlstring:string ="<font face= blackbody size=7 color=\ "red\" > Infinity Interconnect 3G College </font>" the + //BaseURL assigns a path to a resource CSS, using a network path to use CSS on the network - //awebview.loadhtmlstring (htmlstring, Baseurl:nil) $ $ - //define a constant path -Let wordpath:string? = Nsbundle.mainbundle (). Pathforresource ("swiftintroduction", OfType:"docx") the - //initializing a Nsurl object with a string typeWuyiLet wordurl:nsurl! = Nsurl (string: wordpath!) the - //Initialize nsurlrequest with Nsurl object WuLet wordrequest:nsurlrequest =nsurlrequest (Url:wordurl) - About //Loading $ //awebview.loadrequest (wordrequest) - - - //set up what the page view recognizes AAwebview.datadetectortypes =uidatadetectortypes.address + the } - $ Overridefunc didreceivememorywarning () { the super.didreceivememorywarning () the //Dispose of any resources the can be recreated. the } the - in /* the //MARK:-Navigation the About //In a storyboard-based application, you'll often want to do a little preparation before navigation the override func Prepareforsegue (segue:uistoryboardsegue!, sender:anyobject!) { the //Get The new view controller using Segue.destinationviewcontroller. the //Pass The selected object to the new view controller. + } - */ the Bayi //MARK:-Uiwebviewdelegate the theFunc WebView (Webview:uiwebview, Shouldstartloadwithrequest request:nsurlrequest, Navigationtype: Uiwebviewnavigationtype)Bool - { - ifNavigationtype = =uiwebviewnavigationtype.linkclicked the { the the } the - return true the } the the func webviewdidstartload (Webview:uiwebview)94 { the //Start loading the } the 98 func webviewdidfinishload (Webview:uiwebview) About { - //Load completed successfully101 }102 103 func WebView (Webview:uiwebview, Didfailloadwitherror error:nserror)104 { the //Load Failed106}
iOS Development--ui Article Swift &uiwebview