美文网首页
Ios A,B,ViewController传递数据

Ios A,B,ViewController传递数据

作者: wenju | 来源:发表于2021-11-26 15:47 被阅读0次
    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界面")
        }
    }
    

    相关文章

      网友评论

          本文标题:Ios A,B,ViewController传递数据

          本文链接:https://www.haomeiwen.com/subject/sjfxxrtx.html