我有兩個viewCcontroller,FirstViewController和SecondViewController。現在我在FirstViewController中顯示了一個popoverpresentationcontroller,它有一個按鈕,它包含幾個用戶輸入的textFields。現在,一旦按鈕被點擊,我想導航到SecondViewController並傳遞數據。但我無法導航到第二個視圖控制器。如果我從popoverpresentationcontroller的按鈕使用segue到SecondViewController,它會成功導航,但我想通過編程來實現。有關如何做到這一點的任何幫助?從popoverPresentationController導航到新的ViewController
這是我的按鈕,單擊代碼
@IBAction func goTo(_ sender: UIButton) {
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let destination = storyBoard.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
destination.flag = flag
sender: sender)
self.navigationController?.pushViewController(destination, animated: true)
}
}
}