非常简单的情况下,有很多这个帖子,但我仍然坚持。我有一个嵌入在UINavigationController
中的UITableView
最终UIViewController
应该在选择UITableViewCell
时显示。当我将所有这些连接起来时,行选择上没有任何反应。UINavigationController没有后退按钮
我可以得到详细视图,由我们的didSelectRowAtIndexPath
呈现,并通过它的id引用segue。但是,当我这样做时没有后退按钮。
类MainViewController:UIViewController的,的UITableViewDelegate,UITableViewDataSource {
@IBOutlet weak var tableview: UITableView!
var configJson: JSON = []
var config: [Tab] = []
override func viewDidLoad() {
super.viewDidLoad()
parseConfig()
}
func parseConfig() {
let configParser = ConfigParser(configJson: configJson)
config = configParser.parse()
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.config.count
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let tab = self.config[indexPath.row]
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "cell")
cell.textLabel?.text = tab.title
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
performSegue(withIdentifier: "contentSegue", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if (segue.identifier == "contentSegue") {
let nextVC = segue.destination as? ContentViewController
let indexPath = self.tableview.indexPathForSelectedRow
let tab = self.config[(indexPath?.row)!]
nextVC?.tab = tab
}
}
}
一对夫妇的其他注意事项:1。 我IDENTIFER细胞在IB
设置为 '细胞' 2.我的segue在IB
中设置为'show',标识符为'contentSegue'3. Segue从原型单元格到内容Vi新的控制器。
我完全失败。谁能帮忙?谢谢。
请提供您的下一个视图控制器代码 –
没有任何呢。这只是一个空的viewDidLoad()方法。 – Alex
尝试删除你的segue并重新创建它,有时它是有帮助的,也许你从UITabeView或Cell创建它,而不是ViewController –