class AViewController: UIViewController{
@IBAction func nextB(_ sender: UIButton){
let bViewController = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "BViewController") as! BViewController
bViewController.modalPresentationStyle = .fullScreen
bViewController.delegate = self
self.present(bViewController, animated: true, completion:nil)
}
}
extension AViewController:BDelegate{
func bContext(context: String) {
print("回传内容" + context)
}
}
protocol BDelegate{
func bContext(context: String)
}
var delegate: BDelegate!
class BViewController: UIViewController{
@IBAction func editBackBtn(_ sender: UIButton){
self.delegate.bContext(context: "传入数据到A界面")
}
}
网友评论