【问题标题】:Calling popover from a menu item crash从菜单项崩溃中调用弹出框
【发布时间】:2014-11-07 07:07:39
【问题描述】:

我有一个工具栏按钮

@IBOutlet weak var testButton: NSToolbarItem!

按钮调用弹出框并且工作正常。

但是,如果我尝试从顶部菜单项调用弹出框,我会崩溃。 我已经修改了弹出框的位置,使其像往常一样出现在 testButton 下方。 (下面评论)

@IBAction func menuPreviewAndTestAction(sender: AnyObject) {
    var returnedHtmlString = checkEverythingAndCreateTheEncodedHtml(testButton)
    setEncodedHtmlToPreview(returnedHtmlString)
    var thebounds = self.testButton.view?.bounds // so i am givving bounds of button that narmally calls poover
    testingPopover.showRelativeToRect(thebounds!, ofView: sender as NSView, preferredEdge: NSMaxYEdge) // crashes
}

【问题讨论】:

    标签: cocoa swift popover


    【解决方案1】:

    天哪...我错过了更改 ofView,全部排序为:

    var thebounds = self.testButton.view?.bounds
            var theview = self.testButton.view
            testingPopover.showRelativeToRect(thebounds!, ofView: theview! as NSView,      preferredEdge: NSMaxYEdge)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-06
      • 1970-01-01
      • 2011-09-30
      • 1970-01-01
      • 2019-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多