后退按钮到另一个故事板
Back button to another storyboard
我正在创建一个包含 2 个故事板的 iOS 应用程序。
这是第二个:
我的目标是 iOS 7,所以我不能使用故事板参考。故事板之间的切换以编程方式处理
使用此代码:
let viewController:UIViewController = UIStoryboard(name: "Warnings", bundle: nil).instantiateViewControllerWithIdentifier("WarningsInitialView") as UIViewController
self.presentViewController(viewController, animated: true, completion: nil)
我可以使用它进入第二个故事板。然而,正如您所看到的,第二个故事板由 Tab Controller 组成,我想要(在两个选项卡上)后退按钮,它将指向主(上一个)故事板。我该如何实现?
我试过使用这个代码:
AvalanchesBackButton.leftBarButtonItem = UIBarButtonItem (title: "< Spät", style: UIBarButtonItemStyle.Plain, target: self, action: "backButtonClicked")
我将能够通过对两个视图使用不同的视图控制器并对其进行硬编码来实现我想要的。但是有没有办法更干净地做到这一点?比如在容器 Tab Controller 上实现一个后退按钮,它将指向上一个故事板?
提前致谢
您之前的 ViewController 是否嵌入到导航控制器中?因为 "pushing" 视图控制器自动添加后退按钮。
self.navigationController?.pushViewController(viewController: UIViewController, animated: Bool)
我正在创建一个包含 2 个故事板的 iOS 应用程序。
这是第二个:
我的目标是 iOS 7,所以我不能使用故事板参考。故事板之间的切换以编程方式处理
使用此代码:
let viewController:UIViewController = UIStoryboard(name: "Warnings", bundle: nil).instantiateViewControllerWithIdentifier("WarningsInitialView") as UIViewController
self.presentViewController(viewController, animated: true, completion: nil)
我可以使用它进入第二个故事板。然而,正如您所看到的,第二个故事板由 Tab Controller 组成,我想要(在两个选项卡上)后退按钮,它将指向主(上一个)故事板。我该如何实现?
我试过使用这个代码:
AvalanchesBackButton.leftBarButtonItem = UIBarButtonItem (title: "< Spät", style: UIBarButtonItemStyle.Plain, target: self, action: "backButtonClicked")
我将能够通过对两个视图使用不同的视图控制器并对其进行硬编码来实现我想要的。但是有没有办法更干净地做到这一点?比如在容器 Tab Controller 上实现一个后退按钮,它将指向上一个故事板?
提前致谢
您之前的 ViewController 是否嵌入到导航控制器中?因为 "pushing" 视图控制器自动添加后退按钮。
self.navigationController?.pushViewController(viewController: UIViewController, animated: Bool)