我有一个使用 SWRevealViewController 创建的滑出式菜单。滑出式菜单的每一行都连接到一个 NavigationController。 我希望两行的两个不同的 TableViewController 连接到同一个 ViewController 并显示 segue。
当我从第一个 NavigationController 导航时,ViewController 正常工作,并且在导航栏中设置了单击单元格的描述。
class Details: UIViewController {
var name:String = ""
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = name
print(name)
}
相反,当我从第二个 NavigationController 导航时,ViewController 不起作用。不显示导航栏,但打印“名称”参数。
谁能帮我解决这个问题?
最佳答案
您可以添加您的代码并输入索引号。和单元格的标题:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
switch (indexPath.row)
{
case 2: name = "yourFirstNavigationTitleName"
break
case 3: name = "yourSecondNavigationTitleName"
break
default: break
}
}
关于ios - 一个 ViewController 中的多个 NavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43802282/