我正在尝试使用 Swift 为 OS X 编写我的第一个应用程序(没有任何教程或任何内容),这个应用程序将包含两个不同的“页面”。所以我创建了另一个包含第一个 View 的 XIB 文件并将其作为主界面。我创建了一个小“Entry.swift”文件,其中包含第一个 View 的 IBOutlet 和变量,我在其中编写了以下内容:
@IBAction func validation(sender: AnyObject) //Right username and password needed to unlock the second view
{
if (usernameField.stringValue == "Stan" && passwordField.stringValue == "Test") || (usernameField.stringValue == "Nico" && passwordField.stringValue == "Test2")
{
accesLabel.textColor = NSColor.greenColor()
accesLabel.stringValue = "Acces Granted"
//GO TO THE OTHER XIB FILE (1)
}
else
{
accesLabel.textColor = NSColor.redColor()
accesLabel.stringValue = "Acces Denied"
}
}
但我的问题是:
这是从一个窗口转到另一个窗口的最佳方式吗?
和
如果是,我该如何编码? (1)
如果不是,那是什么?
我是 iOS 和 OSX 编程新手,因为我首先学习了 C#...这是我自己的第一个 C# 程序,所以我正在尝试转换它。
最佳答案
您是否尝试过仅使用一个 Storyboard,但隐藏/显示有关您所在位置的按钮?这可能是轻程序的一种方式......
关于macos - Swift 中的 OS X 应用程序 View 管理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25325532/