3 回答

TA貢獻1820條經(jīng)驗 獲得超3個贊
希望這個能對您有所幫助
這是您要從中返回數(shù)據(jù)的第二個控制器。 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 關注
- 458 瀏覽
添加回答
舉報