ios - swift4中点击标签栏时如何始终显示主页?

标签 ios swift

我有代码可以在单击按钮时转到下一页并显示选项卡栏。

@IBAction func moveBtn(_ sender: Any) {
        guard let next = self.storyboard?.instantiateViewController(withIdentifier: "nextPage") as? nextPageCon else {
            return
        }
        self.definesPresentationContext = true
        next.modalPresentationStyle = .overCurrentContext
        self.present(next, animated: false)
    }

我的问题是,当我使用下一页上的标签栏转到另一个页面然后返回时,我想显示主页。

目前,当我使用标签栏移动然后返回时,下一页将按原样显示。

如何修复它?

最佳答案

将其添加到您的 nextPageCon View Controller 中:

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    self.presentingViewController?.dismiss(animated: false, completion: nil)
}

当您呈现 nextPageCon,然后通过选择不同的选项卡导航离开时,此函数将触发并自行关闭。

关于ios - swift4中点击标签栏时如何始终显示主页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53729274/

相关文章:

ios - UIbutton 自动调整大小

ios - 尝试使用 reverseGeocodeLocation,但未执行 completionHandler 代码

iphone - "error launching remote program: device locked out"xcode 4.2.1 和 ipad 5.0.1

ios - UITextView文本未垂直对齐

ios - 自定义iOS导航 Controller 动画: is this wrong?

ios - 不同方向的快速布局

ios - 如何快速将 JSON 字符串转换为 JSON 对象?

ios - 无法使用 JSON 解码器解析 JSON

ios - 有了 MainViewController,如何在 MainVC 中与实际的 UIContainerViews 通信?

swift - 验证 NSTouchBar 项目的最佳实用方法