gpt4 book ai didi

ios - 再次回来时导航栏消失

转载 作者:行者123 更新时间:2023-11-30 12:50:55 24 4
gpt4 key购买 nike

我在 TableView 之上使用 UINavigationBar。每当我触摸单元格并再次返回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

}

最佳答案

override func viewWillAppear(animated: Bool) {
self.navigationController?.navigationBarHidden = false
}

并在下一个 Controller 中使用

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)
}

关于ios - 再次回来时导航栏消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40989735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com