2016-12-06 61 views
0

我在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 

    } 
+0

你在嵌入您的视图控制器uinavigation控制器? – Tj3n

+0

@ Tj3n是的,我喜欢。 – fatemeh

+0

在你的viewdidapper()中写一行self.navigationController.navigationBarHidden = NO; –

回答

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

对不起!它不工作 – fatemeh

+0

你在做什么推或现在?? –

+0

以及您用于隐藏导航栏的哪一行? –

0

再次指派代表到navigationController当你取消隐藏