2017-07-03 19 views
0

我正在运行以下代码并收到以下错误。我已经搜索,但看不到确切的答案。真的很感谢所有的帮助。 新到iOS开发静得通过 感谢XCode 8.2.1 UIView没有成员'加载请求'

import UIKit 

class ViewController: UIViewController { 
    @IBOutlet var WebView: UIView! 

    override func viewDidLoad() { 
     super.viewDidLoad() 
     // Do any additional setup after loading the view, typically from a nib. 
     view.translatesAutoresizingMaskIntoConstraints = false 

     WebView.loadRequest(NSURLRequest(URL:NSURL(fileURLWithPath:Bundle.mainbundle().pathForResource("mashupcode",ofType:"html")!)!)) 
     // This is the web mashup 
    } 

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 
    } 

ERROR工作

Valueoftype '的UIView' 没有成员“的loadRequest

回答

0

看:

@IBOutlet var WebView: **UIView**! 

你webView变量是实际的盟友一个UIView对象。你需要一个实际的UIWebView而不是UIView。大概检查你的故事板,并确保你已经连接正确的iboutlet。