在AppDelegate init()中我有
popover = NSPopover()
popover.behavior = .Transient
popover.contentViewController = ContentViewController()
现在在ContentViewController中:NSViewController
override func loadView() {
view = NSView()
view.translatesAutoresizingMaskIntoConstraints = false
view.addConstraint(NSLayoutConstraint(
item: view, attribute: .Width, relatedBy: .Equal,
toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 580))
view.addConstraint(NSLayoutConstraint(
item: view, attribute: .Height, relatedBy: .Equal,
toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 425))
NSUserDefaults.standardUserDefaults().registerDefaults(["UserAgent": "Tick Mac App"])
let url = NSURL(string: tickExtensionURL )!
var request = NSURLRequest(URL: url)
var webView = WebView(frame: view.bounds)
webView.mainFrame.loadRequest(request)
view.addSubview(webView)
}
如您所见,视图出现但不是WebView。我做错了什么?