Ios 当我从视图返回时,选项卡栏不显示';不显示
在我的应用程序中,我有一个选项卡视图控制器,其中一个选项卡显示与体育相关的内容。在“运动”视图中,只有按钮,我将从按钮切换到另一个视图控制器。当我第一次打开体育活动时,按钮上会显示一个选项卡栏。之后,我单击“运动视图”控制器中的一个按钮转到另一个视图控制器,然后单击“上一步”转到“运动视图”控制器,选项卡栏不显示。另外,我在运动视图控制器中没有代码。以下是单击“运动视图”控制器中的按钮后显示的其中一个控制器的代码。“后退”按钮的代码位于“后退”下。我试过多种不同的方法回去,但都不管用Ios 当我从视图返回时,选项卡栏不显示';不显示,ios,swift,uibutton,back,Ios,Swift,Uibutton,Back,在我的应用程序中,我有一个选项卡视图控制器,其中一个选项卡显示与体育相关的内容。在“运动”视图中,只有按钮,我将从按钮切换到另一个视图控制器。当我第一次打开体育活动时,按钮上会显示一个选项卡栏。之后,我单击“运动视图”控制器中的一个按钮转到另一个视图控制器,然后单击“上一步”转到“运动视图”控制器,选项卡栏不显示。另外,我在运动视图控制器中没有代码。以下是单击“运动视图”控制器中的按钮后显示的其中一个控制器的代码。“后退”按钮的代码位于“后退”下。我试过多种不同的方法回去,但都不管用 impor
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.
}
}
不要从AppDelegate获取NavigationController,而是尝试在GolfViewController本身上使用NavigationController,如下所示:
@IBAction func back_golf(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}