优艾设计网

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

本人超级小小白,现在是这样的,我安装了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 = UIAlertContro优艾设计网_在线设计ller(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)

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


_CFT****84467 2022-09-16 12:47

优艾设计网_设计客

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


0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜