我在UINavigationBar
之上使用了TableView
。每当我触摸cell
并再次返回TableView时,NavigationBar
就会消失。我该怎么办?
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0{
let cell = tableView.dequeueReusableCell(withIdentifier: fa_color_arrayOfCellData[indexPath.row].cell, for: indexPath) as UITableViewCell
let (fa_ColorArgumentsContent) = fa_color_arrayOfCellData[indexPath.row].text
cell.textLabel?.text = fa_ColorArgumentsContent
cell.textLabel?.textAlignment = NSTextAlignment.right
//set the data here
return cell
}
else if indexPath.section == 1 {
let cell = tableView.dequeueReusableCell(withIdentifier: fa_system_arrayOfCellData[indexPath.row].cell, for: indexPath) as UITableViewCell
let (fa_SystemArgumentsContent) = fa_system_arrayOfCellData[indexPath.row].text
cell.textLabel?.text = fa_SystemArgumentsContent
cell.textLabel?.textAlignment = NSTextAlignment.right
//set the data here
return cell
}
else if indexPath.section == 2{
let cell = tableView.dequeueReusableCell(withIdentifier: fa_support_arrayOfCellData[indexPath.row].cell, for: indexPath) as UITableViewCell
let (fa_SupportArgumentsContent) = fa_support_arrayOfCellData[indexPath.row].text
cell.textLabel?.text = fa_SupportArgumentsContent
cell.textLabel?.textAlignment = NSTextAlignment.right
//set the data here
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as UITableViewCell
let (fa_SupportArgumentsContent) = fa_color_arrayOfCellData[indexPath.row].text
cell.textLabel?.text = fa_SupportArgumentsContent
cell.textLabel?.textAlignment = NSTextAlignment.right
return cell
}
答案 0 :(得分:0)
override func viewWillAppear(animated: Bool) {
self.navigationController?.navigationBarHidden = false
}
并在下一个控制器中使用
override func viewWillDisappear(animated: Bool) {
self.navigationController?.navigationBarHidden = false
}
以及
override func viewWillAppear(_ animated: Bool) {
// Hide the navigation bar on the this view controller
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
override func viewWillDisappear(_ animated: Bool) {
// Show the navigation bar on other view controllers
self.navigationController?.setNavigationBarHidden(true, animated: true)
}
答案 1 :(得分:0)
取消隐藏时,再将委托再分配给navigationController