代码之家  ›  专栏  ›  技术社区  ›  Ofri

“后退”按钮后,Uitabar消失

  •  0
  • Ofri  · 技术社区  · 7 年前

    UITableView 用一个 TabBar .

    我又回到从前了 UITableView公司

    只有这一次 不显示。我怎样才能让它再次出现?

    注意:最左边的视图是单击单元格时显示的视图

    视图A和B

    点击“上一步”后-Uitabar不见了

    1 回复  |  直到 7 年前
        1
  •  2
  •   Dris    7 年前

    如果您手动设置“后退”按钮,只需将您的“后退”segue的目的地从viewController设置为navigationController。 但是正确使用TabBar和NavController的方法如下: enter image description here

    有了这个设置,它应该可以工作。

    test

    class ViewController: UIViewController {
    
    var array = ["one", "two", "three"]
    
    @IBOutlet weak var table: UITableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    
     }
    extension ViewController: UITableViewDelegate, UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section:   Int) -> Int {
    
          return array.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
        cell.textLabel?.text = array[indexPath.row]
        return cell
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        performSegue(withIdentifier: "goToDetail", sender: self)
    }
    
    }
    

    既然在视图B中隐藏了选项卡栏,那么只需取消隐藏即可。

    将此代码添加到视图B

        override func viewWillDisappear(_ animated: Bool) {
           super.viewWillDisappear(animated)
           self.tabBarController?.tabBar.isHidden = false
        }