Ios 一个ViewController中有多个NavigationController
我有一个滑动菜单创建使用SWRevealViewController。滑出菜单的每一行都连接到NavigationController。 我希望两行两个不同的TableViewController通过显示序列连接到同一个ViewController 当我从第一个NavigationController导航时,ViewController工作正常,并且在导航栏中设置单击单元格的说明Ios 一个ViewController中有多个NavigationController,ios,swift,xcode,uinavigationcontroller,storyboard,Ios,Swift,Xcode,Uinavigationcontroller,Storyboard,我有一个滑动菜单创建使用SWRevealViewController。滑出菜单的每一行都连接到NavigationController。 我希望两行两个不同的TableViewController通过显示序列连接到同一个ViewController 当我从第一个NavigationController导航时,ViewController工作正常,并且在导航栏中设置单击单元格的说明 class Details: UIViewController { var name:String = ""
class Details: UIViewController {
var name:String = ""
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = name
print(name)
}
相反,当我从第二个NavigationController导航时,ViewController不工作。导航栏未显示,但会打印“名称”参数
有人能帮我解决这个问题吗?试试这个,看看:
override func viewDidLoad() {
super.viewDidLoad()
print(name)
self.navigationItem.title = name
if let navController = self.navigationController {
navController.isNavigationBarHidden = false
} else {
print("There is no Navigation Controller. You may not be showing this controller using 'navigation push'")
}
}
试试这个,看看:
override func viewDidLoad() {
super.viewDidLoad()
print(name)
self.navigationItem.title = name
if let navController = self.navigationController {
navController.isNavigationBarHidden = false
} else {
print("There is no Navigation Controller. You may not be showing this controller using 'navigation push'")
}
}
您可以添加代码并输入单元格的索引号和标题:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
switch (indexPath.row)
{
case 2: name = "yourFirstNavigationTitleName"
break
case 3: name = "yourSecondNavigationTitleName"
break
default: break
}
}
您可以添加代码并输入单元格的索引号和标题:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
switch (indexPath.row)
{
case 2: name = "yourFirstNavigationTitleName"
break
case 3: name = "yourSecondNavigationTitleName"
break
default: break
}
}
在didSelectRowAtIndexPath like中放入条件(如果indexPth.row==2)并通过编码导航我认为您没有使用推送,或者使用当前导航解决了您的问题,或者仍然面临相同的问题?我已经消除并重新创建了显示序列,问题似乎已经解决。在我的例子中,最好的解决方案是将两个不同的NavigationController连接到一个viewcontroller以通过show segue显示详细信息吗?或者我应该采取另一种解决方案吗?将条件像(如果indexPth.row==2)一样放入didSelectRowAtIndexPath中,并通过编码进行导航我认为您没有使用推送,或者使用当前导航解决了您的问题,或者仍然面临相同的问题?我已经消除并重新创建了显示序列,问题似乎已经解决。在我的例子中,最好的解决方案是将两个不同的NavigationController连接到一个viewcontroller以通过show segue显示详细信息吗?还是我应该采取另一种解决方案?