2016-11-10 36 views
1

我在視圖控制器與這樣的(第二控制器)的約束網頁視圖:網頁web視圖中填寫的問題迅速3

enter image description here

我的問題是,當顯示網頁,該網頁不補全網頁視圖和有(底部以上)的白色空間是這樣的:

enter image description here

我設置控制器,其中有webPageview以這種方式:

class xViewController: UIViewController , UIWebViewDelegate { 

    @IBOutlet var webV : UIWebView! 
    var url = "" 
    var reloadIcon : UIRefreshControl? 

    override func viewDidLoad() { 

     super.viewDidLoad() 


     self.reloadIcon = UIRefreshControl(frame: CGRect(x: UIScreen.main.bounds.width-20, y: 20, width: 40, height: 40)) 




     //self.webV = UIWebView(frame: CGRect(x: 0, y:0, width : UIScreen.main.bounds.width, height : UIScreen.main.bounds.height - 44)) 
     self.webV.scalesPageToFit = true 
     self.webV.contentMode = .scaleToFill 
     self.webV.isOpaque = false 
     self.webV.backgroundColor = UIColor.clear 
     self.webV.delegate = self 
    } 
    override func viewWillAppear(_ animated: Bool) { 

     super.viewWillAppear(animated) 
     self.webV.isHidden = true 
     self.webV.loadRequest(NSURLRequest(url: NSURL(string: self.url)! as URL) as URLRequest) 
    } 
    func resfreshWebView(){ 

     self.webV.isHidden = true 
     webV?.reload(); 
    } 
    func webViewDidFinishLoad(_ webView: UIWebView){ 


    } 
    func webView(_ webView: UIWebView, didFailLoadWithError error: Error) { 


    } 
    func webViewDidStartLoad(_ webView: UIWebView){ 

     self.webV.isHidden = false 
    } 



} 

P.S我注意到在故事板上有兩個欄(黑色和灰色),我不明白爲什麼。

回答

0

我首先想到的就是儘量self.automaticallyAdjustsScrollViewInsets = false

0

您需要從所有的邊設置你的佈局像這樣

enter image description here

enter image description here

設置在此之後佈局Web視圖在全視圖中顯示,請檢查屏幕截圖

enter image description here