Swift里使用了Eureka,如何将TextRow里面的值调用出来? 财富值66

2016-11-02 00:04发布

本人超级小小白,现在是这样的,我安装了Eureka开源框架并且用它创建了3行text row,用户填入内容后,我需要app里调用这3行text row里用户输入的值,试了很久都不行。
以下是代码:

 import UIKit import Eureka class ViewController: FormViewController{  override func viewDidLoad() {     super.viewDidLoad()     // Do any additional setup after loading the view, typically from a nib.          //Set title for Navi Bar     self.title="Data Manager"          //Add one Section without title     form +++ Section ("")          //Add Text Row         <<< TextRow("FirstTag"){ row1 in             row1.title = "Project code"             row1.placeholder = "Enter Project Code here"             }.onChange { row1 in                 print(row1.value)}         <<< TextRow("SecondTag"){ row2 in             row2.title = "Username"             row2.placeholder = "Enter Username here"             }.onChange { row2 in                 print(row2.value)}         <<< TextRow("ThirdTag"){ row3 in             row3.title = "Password"             row3.placeholder = "Enter Password here"             }.onChange { row3 in             print(row3.value)}          // add "Log on" button     let myFirstButton = UIButton()     myFirstButton.setTitle("Log In", for: .normal)     myFirstButton.setTitleColor(UIColor.white, for: .normal)     myFirstButton.backgroundColor = UIColor.blue     myFirstButton.frame = CGRect(x: 65, y: 260, width: 250, height: 50)     myFirstButton.addTarget(self, action: #selector(self.pressed), for: .touchUpInside)     self.view.addSubview(myFirstButton)           }      func pressed() {         let alertController = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert)         let okAction = UIAlertAction(title: "OK", style: .default, handler: nil)                  alertController.addAction(okAction)                  self.present(alertController, animated: true, completion: nil)                  print(TextRow.init(tag: "FirstTag").value)     }  override func didReceiveMemoryWarning() {     super.didReceiveMemoryWarning()     // Dispose of any resources that can be recreated. }

}

在viewLoad函数里面的onChange函数是可以的,可以print出返回值。但是我试图加了一个Alert message,目的是出现这个message 的时候可以print返回值,也就是这段代码,就报错了
print(TextRow.init(tag: "FirstTag").value)

不知道有人知道吗?小妹在此谢过了!!

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
1条回答

想了一下 是不是第一个函数没有返回值让第二个函数调用呀

一周热门 更多>