Protocol Delegate Method is not called in Swift

后端 未结 3 1262
故里飘歌
故里飘歌 2020-12-21 21:45

Protocol delegate method is not called..

First View controller code

class ViewController: UIViewController,customDelegate {

  var          


        
3条回答
  •  别那么骄傲
    2020-12-21 21:58

    So basically in line var seconviewcontroller : SecondViewController = SecondViewController() is different from your pushing view controller instance.

    You are making a separate instance of SecondViewController so you have done delegate self at the time of pushing with pushes object like that

    let secondVCInstance = self.storyboard?.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
    secondVCInstance.delegate = self
    self.navigationController?.pushViewController(secondVCInstance, animated: true)
    

    NOTE: - EVERY OBJECT HAS ITS OWN PROPERTIES

提交回复
热议问题