将WebView添加到NSPopover并不会显示WebView,只显示NSView

时间:2015-04-09 22:40:25

标签: macos swift webview nsview nspopover

在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)

    }

enter image description here

如您所见,视图出现但不是WebView。我做错了什么?

0 个答案:

没有答案