ios - 程序化导航后退按钮未显示

标签 ios swift

enter image description here

这是我在应用程序委托(delegate)中的代码:

  func showMainView()
  {
    self.window = UIWindow(frame: UIScreen.main.bounds)
    let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let secondViewController = storyBoard.instantiateViewController(withIdentifier: "PRODUCT_TABBAR_VC_ID")
    let nav = UINavigationController()
    nav.pushViewController(secondViewController, animated: true)
    self.window!.rootViewController = nav
    self.window!.makeKeyAndVisible()
  }

模拟器输出:

enter image description here

基本上我希望当用户按下后退按钮然后返回主页时。我的意思是初始页面。

我正在尝试这个,但它至少对我来说没有一个答案 Navigate Back to previous view controller

注意:@matt 说这是不可能的。那么你能告诉我我该怎么办吗?我是 iOS 新手

更新:

当用户选择Man时,tabviewcontroller的两个页面仅显示有关Man的产品列表。因此,如果用户想看到Woman,然后用户返回主页选择Woman,那么他将看到Woman tabviewcontroller 两个页面。

最佳答案

后退按钮用于返回到推送到 UINavigationController 上的早期 View Controller 。在您的代码中,没有后退按钮,因为没有什么可返回的; secondViewController 是推送到 UINavigationController 上的唯一 View Controller 。

关于ios - 程序化导航后退按钮未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40939977/

相关文章:

ios - 如何将字符串数据发送到 UIButton 标签?

ios - 明确告知计时器后,计时器未启动

ios - 如何在qemu上安装Apple iOS

ios - 自动布局降低某些 View 的高度

ios - Assets 目录与文件夹引用 : When to use one or the other?

xcode - 如何在 Xcode 中查看打印信息?

swift - 使用 Unresolved Identifier 添加第二个 pin MapKit swift

swift - 我希望我已经登录的用户将我的 ViewController3 作为 rootViewController,而那些未登录的用户将 ViewController2

objective-c - 类似 AOP 的 Objective-c 结构

ios - 如何使用 collectionView 自动滑动图像