- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在窗口加载后立即将 Storyboard显示为工作表。
override func windowDidLoad() {
super.windowDidLoad()
let storyboard = NSStoryboard(name: NSStoryboard.Name(rawValue: "Init"), bundle: nil)
let controller = storyboard.instantiateInitialController() as! NSViewController
self.window!.contentViewController?.presentViewControllerAsSheet(controller)
}
不幸的是,工作表显示错位并位于窗口后面。当我在按钮内运行相同的代码时,一切正常。
如何在加载窗口后正确显示 Storyboard 表?
最佳答案
我对 iOS 生态系统有更多了解,但我认为您应该仅在显示原始窗口后才显示新窗口。 windowDidLoad
在加载 View 时调用,而不是在显示 View 时调用。
因此,您可能应该将代码放入 contentViewController
的 viewDidAppear
中。
关于swift - 从 windowDidLoad 启动 ViewController 作为工作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50199360/
我有一个重写 ReactiveWindowController 的类。 我需要获取基类中观察者的引用。但因为它不在那里。我决定覆盖它。 /// public override void Wi
我有一个使用 NSWindowController 子类的简单 Cocoa 应用程序。在我设置的 Nib 中: 将所有者的类文件保存到我的 NSWindowController 子类 文件所有者到 N
这让我发疯。我的应用程序中有几个窗口,我通过菜单打开它们。我现在添加了一个新窗口,但它是 windowDidLoad从未被调用过。 fileprivate let paymentWindowContr
当我们必须使用这些方法时,您能解释一下吗?以及在什么样的情况下我们应该使用哪种方法?现在我测试哪个有效并使用它(是的,我是初学者)..谢谢。我正在为 MAC 进行开发。 最佳答案 首先,你永远不应该自
我试图在窗口加载后立即将 Storyboard显示为工作表。 override func windowDidLoad() { super.windowDidLoad() let sto
我刚刚试用了 Xcode 6 中包含的新 mac Storyboard功能。我使用 Storyboard和 swift 设置了一个新的 OS X 项目,然后我创建了一个新文件 MainWindowCo
我是一名 iOS 开发人员,打算开发一个 OS X 应用程序。然而,他们彼此之间却有很大不同。 我想在应用程序启动时添加启动画面。 - (void) applicationDidFinishLaunc
我正在使用以下代码创建一个窗口: if(hudWindow == nil) hudWindow = [[TimelogWindowController alloc] initWithWindo
我是一名优秀的程序员,十分优秀!