3 回答
TA贡献1820条经验 获得超2个赞
希望这个能对您有所帮助
这是您要从中返回数据的第二个控制器。 SecondView.swift
@objc protocol returnDataProtocol {
func returnStringData(myData: String)
}
class SecondView: UIViewController {
weak var delegate: returnStringData?
@IBAction func readyButtonPressed(sender: AnyObject) {
// Do what you want here
delegate?.returnStringData("Euro/Dollar etc....")
// this function is exist in first view controller
}
}
第一个视图ViewController firstView.swift
class firstView: UIViewController, returnDataProtocol {
// this function will call to second view. You can use here push method, if you are using navigation controller.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "mySegue" { // your identifier here
let controller = segue.destinationViewController as! MyPopOverController
controller.delegate = self
}
}
// here you will get return value from second view controller class
func returnStringData(myData: String){
print(myData)
}
}
- 3 回答
- 0 关注
- 422 浏览
添加回答
举报