作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我构建了一个在登录过程开始时运行的 macOS 框架,我想在一个窗口中向用户显示一些信息。我有一个带有 .XIB 文件的 NSWindowController,它是我的框架的主窗口。
我想将更多 presentAsSheet 添加到另一个 View 。为此,我创建了一个带有 .XIB 的 NSViewController 来定义我想在模态中呈现的用户界面,但在这里我完全被阻止了,因为获取窗口的 contentViewController 总是 nil
我正在像这样初始化我的主窗口:
func run() {
NSApp.activate(ignoringOtherApps: true)
mainWC = MainWC(windowNibName: "MainWC")
guard mainWC.window != nil else {
return
}
NSApp.runModal(for: mainWC.window!)
}
我试图在其中展示另一个 NSViewController"
self.window?.contentViewController?.presentAsSheet(customViewController)
在我的 MainWindowController 中,我这样做:
@IBAction func btnAction(_ sender: Any) {
let customModal = CustomModal(windowNibName: "CustomModal")
self.window?.beginSheet(customModal.window!, completionHandler: { code in
print(message: "Clicked")
})
}
模态框从不出现
最佳答案
在加载窗口和内容 View 之前,您无法呈现 View
要么在 windowDidLoad()
的窗口 Controller 内
override func windowDidLoad() {
super.windowDidLoad()
// present the view
}
甚至在 View Controller 的 viewDidLoad
中
override func viewDidLoad() {
super.viewDidLoad()
// present the view
}
关于swift - 在不使用 Storyboard 的情况下从 NSWindowController 呈现模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55560970/
我来自 Asp.Net 世界,试图理解 Angular State 的含义。 什么是 Angular 状态?它类似于Asp.Net中的ascx组件吗?是子页面吗?它类似于工作流程状态吗? 我听到很多人
我一直在寻找 3 态拨动开关,但运气不佳。 基本上我需要一个具有以下状态的开关: |开 |不适用 |关 | slider 默认从中间开始,一旦用户向左或向右滑动,就无法回到N/A(未回答)状态。 有人
我是一名优秀的程序员,十分优秀!