ios - 按下按钮时呈现新 ViewController 时如何显示 tabBarController

标签 ios swift uiviewcontroller uitabbarcontroller completionhandler

我有一个activityfeedVC。如果用户单击 tableViewCell,则会显示 ActivityVC。在这个 VC 中,我有一个“后退”按钮。单击此按钮后,我想返回到上一个 View Controller 。我能够实现这一点,但无法显示 tabBarController。我正在使用完成处理程序,但出了点问题。希望你能帮忙。

import UIKit

class activityVC: UIViewController {

    @IBAction func backBtnWasPressed(_ sender: Any) {

        // Navigates back
        let feedVC = storyboard?.instantiateViewController(withIdentifier: "feedVC")

        func completionHandler() {
            // show the tabBarController - NOT WORKING
            feedVC?.tabBarController?.tabBar.isHidden = false
            print("tabBarController shown")
        }

        present(feedVC!, animated: false, completion: completionHandler)



    }



    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }



}

我想我应该使用 UINavigationBar 而不是我的客户导航...也许这更容易,即使我没有很多需要此功能的 View ...

最佳答案

您是否将 ActivityVC 推送到 View Controller 堆栈上?如果是这样,您只需在用户点击后退按钮时弹出 ActivityVC 即可。

class activityVC: UIViewController {

   @IBAction func backBtnWasPressed(_ sender: Any) {
      self.navigationController?.popViewController(animated: false)
   }
}

关于ios - 按下按钮时呈现新 ViewController 时如何显示 tabBarController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47237803/

相关文章:

ios - UIWebview 花费太多时间在 iOS 7 中加载 html 内容

ios - 将在代码中创建一个 View ,如何在 Swift 1.2 中声明 int

ios - Swift:奇怪的 XCode 行为在 NSArray 的子类中具有必需的初始化程序

ios - 我怎样才能在 Firebase 中获得现有和新 child 的结果?

ios - UIPageViewController 具有未知数量的 UIViewController 实例

iOS : UIImage created by UIBezierPath not smooth

javascript - 在 keyup 函数运行时保持 iOS 键盘打开

ios - objective c 以编程方式解除分配/释放对象

iOS 11 - 针对自定义 View Controller 未加载的建议 - 崩溃

iphone - UIViewController 从 View 堆栈中弹出,NSURLConnection 使应用程序崩溃