【发布时间】:2017-10-29 23:08:31
【问题描述】:
我正在使用我以编程方式创建的 UITabBarController 来呈现我在 Storyboard 中创建的 UIViewController。我用
呈现这些let storyboard = UIStoryboard(name: "Main", bundle: nil)
// create tab one
let tabOne = storyboard.instantiateViewController(withIdentifier: "feedVC")
let tabOneBarItem = UITabBarItem(title: "feed", image: UIImage(named: "feed_icon"), selectedImage: UIImage(named: "feed_icon_selected"))
tabOne.tabBarItem = tabOneBarItem
self.viewControllers = [tabOne]
在我不显示 TabBar 的选项卡之一中,我在左上角有一个取消按钮。我更喜欢这样将用户送回之前的 ViewController。但要解决一个特定的问题。下面的代码有效,但 TabBarController 不显示......实现取消/返回按钮的最有效方法是什么。
我应该使用 UINavigationController - 还是有更好的选择?
@IBAction func cancelBtnWasPressed(_ sender: Any) {
let returnVC = storyboard?.instantiateViewController(withIdentifier: "feedVC")
present(returnVC!, animated: true, completion: nil)
}
【问题讨论】:
标签: ios xcode navigation nav swift4