我有以下情况:
我在我的viewDidLoad:
self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(title: "New", style: .Plain, target: self, action: "newProject")
我的问题是,我怎样才能通过使用segue“显示(例如推送)”以编程方式点击此按钮移动到另一个Viewcontroller。
我的开头是这样的:
func newProject() {
}
但我不知道更多,因为我是 Swift 的初学者。
任何帮助将非常感激!
更新:
因此,这是出现错误的整个区域:
class NewProject: UIViewController, UITextFieldDelegate, UITextViewDelegate, CustomPickerDelegate {
@IBOutlet weak var txtProjectName: UITextField!
@IBOutlet weak var tvDescription: UITextView!
@IBOutlet weak var txtStartDate: UITextField!
@IBOutlet weak var txtEndDate: UITextField!
var hud: MBProgressHUD?
var customPicker: CustomPickerView?
var dictProject: NSDictionary!
var projectID: String!
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = "Create new Project"
self.hud = MBProgressHUD(view: self.view)
self.view.addSubview(self.hud!)
self.projectID = ("\(self.dictProject!["id"]!)")
self.populateFields()
}
func populateFields() {
if nil != self.dictProject!["name"] {
self.txtProjectName.text = self.dictProject!["name"] as? String
}
}
错误出现在此行:
self.projectID = ("\(self.dictProject!["id"]!)")
这条线在这里:
if nil != self.dictProject!["name"] {