我有一個提交的UIButton是針對這個功能,我有一個textField,我想傳遞到下一個視圖控制器。因此,用戶可以輸入textField,無論輸入什麼內容,一旦用戶點擊提交按鈕,文本字段內的字符串將被傳遞到下一個視圖控制器的UILabel。如何通過導航推送數據視圖控制器
func submitTapped() {
let secondViewController = SecondViewController(nibName: nil, bundle: nil)
navigationController?.pushViewController(secondViewController, animated: true)
print("Button tapped")
}
}
如何通過第二個控制器推送該字符串?另外,我嘗試過使用prepareForSegue,但我認爲這與segues無關,因爲我們不是通過segue轉換屏幕,我們是通過導航控制器轉換的,對嗎?
謝謝!
哦,我解決了這個問題。我所要做的就是從secondViewController訪問標籤。謝謝! –
[在視圖控制器之間傳遞數據]的可能重複(http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) –