我将导航控制器用作根View Controller,并在启动该应用程序时出现一个ViewController VC1,其中包含一个按钮,按下该按钮时(在segue的帮助下)会将您带到具有表格视图和5个单元格的VC2,现在,我想使用推式代替Segue或提出一种从VC2转到VC3的方式(单击单元格)。
我用过
let displayVC : ForWebViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ForWebViewController") as! ForWebViewController
self.navigationController?.pushViewController(displayVC, animated: false)
该代码已置于第一个单元格单击的作用下,但没有任何反应。
谁能帮忙
答案 0 :(得分:0)
以编程方式添加导航控制器
buttonColor: ThemePalette = 'primary';
答案 1 :(得分:0)
let displayVC : ForWebViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ForWebViewController") as! ForWebViewController
present(displayVC, animated: true, completion: nil)
或
navigationController?.pushViewController(displayVC, animated: true)
答案 2 :(得分:0)
目标C:
PulseNavigationController * VC3 =(PulseNavigationController*)navigationcontroller;
[homeNavictrl pushViewController:VC3 animated:YES];
迅速:
let VC3 = NewViewController()
self.navigationController?.pushViewController(VC3, animated: true)
答案 3 :(得分:0)
使用此代码和您的情节提要ID
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print(indexPath.section, indexPath.row)//It will print index and section
let hvc = self.storyboard?.instantiateViewController(withIdentifier: "Your Storyboard ID") as! ForWebViewController//Here replace your class name
self.navigationController?.pushViewController(hvc, animated: true)
}
答案 4 :(得分:0)
您可能会遇到的问题可能是其中一种。请检查以下几点:
1。。您是否将delegate
中的tableView
设置为VC2
。您可以在storyboard
的{{1}}本身或viewDidLoad()
的{{1}}中进行操作,编写以下代码:
VC2
2。。在以下代码中检查self.tableView.delegate = self
实例是否不是navigationController
:
nil