再次回来时,导航栏消失了



我在TableView顶部使用了UINavigationBar。每当我触摸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
    }
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)
}

当您不将其解开时,请再次分配委托书

最新更新