[英]Navigation bar disappears when come back again
I'm using a UINavigationBar
on top of my TableView
. 我在
TableView
顶部使用UINavigationBar
。 Whenever I touch a cell
and come back to the TableView again NavigationBar
disappears. 每当我触摸一个
cell
并再次返回TableView时, NavigationBar
消失。 What shall I do? 我该怎么办?
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
}
override func viewWillAppear(animated: Bool) {
self.navigationController?.navigationBarHidden = false
}
and in next controller use 并在下一个控制器中使用
override func viewWillDisappear(animated: Bool) {
self.navigationController?.navigationBarHidden = false
}
and also 并且
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)
}
取消隐藏时,再次将其分配给navigationController
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.