我将从标签栏 Controller View 转到另一个不属于标签栏 Controller 的 View 。当我尝试通过按后退按钮从 View 返回到选项卡栏 Controller View 时,选项卡栏不显示。按钮的代码在 back_golf 下。该 View 不在导航 Controller 中
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.
}
}
最佳答案
您似乎已经弹出了 ViewController(在本例中为“Golf”)。如果这是真的,这应该适用于:
@IBAction func back_golf(_ sender: Any) {
self.dismiss(animated: true, completion: nil)
}
关于ios - 当我从 View 回到标签栏 Controller 时,标签栏不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51014266/