ios - 当我从 View 回到标签栏 Controller 时,标签栏不显示

标签 ios swift uibutton uitabbarcontroller

我将从标签栏 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.
}
}

Here's a picture that might help

最佳答案

您似乎已经弹出了 ViewController(在本例中为“Golf”)。如果这是真的,这应该适用于:

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

关于ios - 当我从 View 回到标签栏 Controller 时,标签栏不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51014266/

相关文章:

ios - 将核心数据属性类型从 Integer32 更改为 String

ios - 在 table 上显示离用户最近的位置列表

objective-c - 在 super View 中查找 subview 的位置

swift - 在没有 URL 的情况下使用 ZIPFoundation

ios - 将 UITableViewCell 中的 UIButton 转换为自定义类不起作用

objective-c - 为什么这些 Objective-C 和 Swift 子类的行为不同?

ios - iMessage 扩展 : Root Navigation Controller results in all delegate methods to not get called in my MSMessagesAppViewController

swift - 为什么需要字符串来确定第 N 个字符的索引?

ios - prepareForSegue 清空我的 NSManagedObject 数组

ios - 为什么从自定义 UIView 向 UIButton 添加 subview 不显示添加的 subview ?