[問題] swift UINavigationController 傳遞參數
請問一下 如果不使用storyboard開發(已經移除)
單純用純程式碼的方式來進行開發(直接用UINavigationController()來建立元件)
那請問不同的UIViewController 要如何 傳遞參數?
我上網查資料大部分傳遞都需要使用到stoyboard identifier
如下
func onClick() {
// 這邊就會發說錯誤, 錯誤訊息為沒有ShowArticle storyboard
self.performSegue(withIdentifier: "ShowArticle", sender: "message")
self.navigationController?.pushViewController(myArticleViewController(),
animated: true)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if(segue.identifier == "ShowArticle") {
let controller = segue.destination as! ArticleViewController
controller.parameter = sender as! String
}
}
如果沒有stoyboard ideentifier 純程式碼開發的方式進行傳送嗎?
註 : 畫面切換方式我使用UINavigationController來進行切換
謝謝各位
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.34.181.227
※ 文章網址: https://www.ptt.cc/bbs/MacDev/M.1484475802.A.760.html
※ 編輯: tas72732002 (114.34.181.227), 01/15/2017 18:27:45
→
01/15 18:32, , 1F
01/15 18:32, 1F
推
01/15 18:39, , 2F
01/15 18:39, 2F
→
01/15 18:39, , 3F
01/15 18:39, 3F