如何在最大化的窗口控制器之上打开窗口控制器

时间:2018-04-16 19:49:27

标签: swift macos nsviewcontroller nswindowcontroller

我有一个带有mainwindowController的osx(MacOS)应用程序,用户可以最大化视图。该应用程序还有一个首选项窗口,可作为childwindowcontroller打开。

但是,如果主窗口最大化,子窗口也会尝试最大化,最终会出现黑屏,子窗口显示在中间。

无论如何都要根据主窗口最大化状态显示子窗口,并且子窗口始终不会最大化。

以下是一些如何显示偏好设置窗口的代码。

def solve (slots, reqs, periods):
    # binary variable to id if combination is used
    x = pulp.LpVariable.dicts('slot', slots, lowBound=0, upBound=1, cat=pulp.LpInteger)

    # linear program problem
    sked_model = pulp.LpProblem("NLE Specials Scheduling Model", pulp.LpMaximize)

    # objective function
    sked_model += sum([x[slot] for slot in slots]), "Slot selection" # all combinations considered equal

    # Supply maximum number of slots
    sked_model += sum([x[slot] for slot in slots]) == len(reqs), "Number_of_slots to sked"

1 个答案:

答案 0 :(得分:0)

解决它 - 当我创建窗口时,我添加一个样式蒙版来将新窗口设置为不可调整大小。 (最后一行代码)

if let subPreferenceViewController = storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: "sub-preferences")) as? SubPreferenceViewController {
            let subPreferenceWindow = NSWindow(contentViewController: subPreferenceViewController)
            let subPreferenceWindowController = SubPreferenceWindowViewController(window: subPreferenceWindow)
            var windowControllersForCurrent =  windowControllers[currentWindowController]
            windowControllersForCurrent?.append(subPreferenceWindowController)
            windowControllers[currentWindowController] = windowControllersForCurrent
            newWindowController = subPreferenceWindowController
            newWindow = subPreferenceWindow
            newWindow.standardWindowButton(.zoomButton)!.isHidden = true
            width = 400
            height = 607
            newWindow.maxSize = NSSize(width: width, height: height)
            newWindow.styleMask.remove(.resizable)
        }