当我从视图回到标签栏控制器时,标签栏不显示

时间:2018-06-24 21:48:11

标签: ios swift uibutton uitabbarcontroller

我要从标签栏控制器视图转到另一个不是标签栏控制器一部分的视图。当我尝试从视图返回到标签栏控制器视图时,通过按“后退”按钮,标签栏不会显示。该按钮的代码在back_golf下。该视图不在导航控制器中

import UIKit
import Firebase

class Golf: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableview_golf: UITableView!

var array = [String]()
var ref : DatabaseReference!
var handle: DatabaseHandle!

@IBAction func back_golf(_ sender: Any) {


let appDelegate = UIApplication.shared.delegate as! AppDelegate
let navigationController = appDelegate.window?.rootViewController as! 
UINavigationController

 navigationController.dismiss(animated: true, completion: nil)
  //self.navigationController?.popToRootViewController(animated: true)
 //self.performSegue(withIdentifier: "seque_golf", sender: nil)
 //hidesBottomBarWhenPushed = false
}
override func viewDidLoad() {
super.viewDidLoad()
ref = Database.database().reference()
handle = ref?.child("Girls_golf").observe(.childAdded, with: { 
(snapshot) in
    if let item = snapshot.value as? String {
        self.array.append(item)
        self.tableview_golf.reloadData()
    }

})


}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: 
Int) -> Int {
return array.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: 
IndexPath) -> UITableViewCell {
let cell = tableview_golf.dequeueReusableCell(withIdentifier: 
"golf_cell")! as UITableViewCell
cell.textLabel?.text = array[indexPath.row]
cell.textLabel?.numberOfLines = 0
return cell
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

Here's a picture that might help

1 个答案:

答案 0 :(得分:0)

似乎您已经弹出了ViewControllers(在此示例中为“ Golf”)。如果是这样,则应适用于:

@IBAction func back_golf(_ sender: Any) {
    self.dismiss(animated: true, completion: nil)
}