我使用自定义表格 View 单元将表格 View 填充为菜单并将其用作菜单。我能够使用导航 Controller 导航到其他 View 。
但我想以编程方式创建 View 及其控件。可能吗?
谁能给我一个例子。请在下图中找到我的菜单结构。
最佳答案
我就是这样做的。它就像一个魅力!!!
func tableView(_tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//Remove the below line from this function as it will perform segue.
//performSegue(withIdentifier: "DynamicSegue", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) {
// This will actually perform your segue
var DestViewController = segue.destination as! DynamicSuperView
let selectedRow = tableView.indexPathForSelectedRow?.row
DestViewController.labelText = names[selectedRow!]
}
关于ios - 如何在 Swift 中以编程方式创建 View Controller 及其控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38908156/